Announcement

Collapse
No announcement yet.

Automatic swing recording with OBS Studio

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic swing recording with OBS Studio

    This is a tutorial on how to setup OBS studio for live streaming/instant replay. You do not need to live stream for this to work.

    Step 1

    Download OBS Studio, Voice attack, and Audio zone trigger.

    Step 2 Setting up OBS Studio:

    1. Open the OBS Studio settings, go to output, and check the box "Enable Replay Buffer"
    Set the length to your desired time. Note: Longer replay buffers require more memory. For this guide we'll use 5 seconds.

    2. In the general settings, check the box to Automatically start replay buffer when streaming.

    3. In the Hotkey settings, set a hotkey for saving the replay buffer. For this guide, we'll use Ctrl+Shift+S.
    Using this hotkey you can still save replays normally, even with Instant Replays setup.

    4. Now, close the settings page and start the replay buffer by clicking on "Start Replay Buffer" towards the bottom right of OBS Studio.

    5. Add a new media source to the current scene, we'll call it "Instant Replay" for this guide, and select the Replay buffer file.
    By default it will be located in the “Videos” folder and the file name will start with Replay.

    6. At the top of OBS Studio, click on tools, then scripts and select “instant-replay.lua”

    7. From the Media Source drop down menu, select the media source you just added to the scene. Then hit close.
    If the media source is not appearing, click on the refresh icon to the left.

    8.Open up the OBS Studio settings again and go to the Hotkeys section. There will be a new hotkey, called "Instant Replay".
    For this guide, we'll set the hotkey to Ctrl+Shift+R.

    9. Now your Instant Replay feature is ready. Simply press the hotkey combination you just chose, and the last 5 seconds will play in the media source. You can now resize the source and move it around.

    10. Add your camera inputs.

    Step 3 Setting up Voice Attack

    1. Open voice attack

    2. Select the option to edit profile

    3. Delete all actions.

    4. Select new command

    5. Setup the command to correspond to the provided screen shot

    6. Hit ok then apply.

    Step 4 Setup Audio Zone Trigger.

    1. Setup According to screen shot, Activate a Key which is f12

    Step 5 Arranging the windows

    1. I can't really walk you though this part but here you will arrange all the windows to fit on your OBS layout. the boxes are all drag and drop.

    2. Change the speed of the "Instant Replay" box to what ever you like. I have mine set at 35.

    3. Once you have everything arranged select lock preview.


    Now you should be all set to go. Here is my setup. Im using 3 cameras.

    Any questions or suggestions I would be glad to help.



    Advanced Version using OBS Plugin plugin Replay Source:

    Ok I'm going to assume you are somewhat comfortable with Obs, you can add camera inputs, and install plugins.

    Step 1 Installing Replay Source OBS

    1. Download from https://github.com/exeldro/obs-replay-source/releases

    2. Unzip the download in the 64 bit plugins folder for example: C:\Program Files (x86)\obs-studio\obs-plugins\64bit

    Step 2 OBS

    1. Create a new scene

    Step 3 OBS

    1. Add one video capture source name it DTL, make sure to adjust the camera and set it to highest fps

    2. Add "ReplayInput" source, name it DTL slow, then select your camera and change the following values:
    Duration 4
    Maximum replays 1

    3. Go to the hot keys section. Find the "DTL slow" source, add shift+S as the hotkey to "Load Replay"

    Step 4 Audio zone trigger

    1. Use the same settings as the previous guide, on trigger press f12

    Step 5 Voice attack

    1. disable / delete the previous command.

    2. Create a command that triggers on f12, pauses for 2 seconds, then presses Shift+S

    Step 5

    1. Hope it works


    Here is a live example if I'm online:
    Twitch is the world's leading video platform and community for gamers.



    Last edited by htdumps; 01-27-2019, 07:24 PM.

  • #16
    Originally posted by FaultyClubs View Post
    My previous post showed OBS reducing my 120 fps camera down to 60 fps for recording and slow motion playback. I explained in the comments to that post what appeared to be happening.

    I had some time today to perform more tests as described below.

    I tested with my 120 fps global shutter camera. I picked this because it has only one video mode which is 1280x720 at 120 fps. It has no other modes or speeds which can be mistakenly used to confuse the test results. I then set OBS internal frame rate to 30 fps (Settings/Video/FPS) so the speed difference would be obvious (120 vs 30) if OBS re-encodes the camera down to that rate at any point.

    1) First test was the one I asked HT to do above (although I wanted him to use his 330 fps camera). Run OBS at 30 fps (Settings/Video/FPS=30) and my camera at 120 fps. Then dump the replay's memory buffer. It will be at 120 fps if OBS is capturing at the full rate. Otherwise it'll be 30 fps.

    Result: Rate is 30 fps.

    2) Second test was the stop watch test. I recorded my phones digital stop watch. At 120 frames per second there will be 12 frames for every 0.1 second tick over. 30 fps will have 3 frames every 1/10 of a second. I then dumped the replay memory buffer and stepped through it frame by frame counting how many frames per 1/10 of a second tick mark.

    Result: 3 frames every 1/10 of a second tick mark = 30 fps

    3) Third test was only looking at the slow motion replay. I set the playback speed to 1%. At 120 frames per second this means there will be 1.2 frames per second (or 2.5 seconds for three frames). At 30 fps there will be 0.3 frame per second (or 10 seconds for three frames). I then captured a moving object (big arm wave) to make it easy to see when a new frame occurs and measured the time for three frames.

    Result: 10 seconds for three frames = 30 fps

    4) I redid test #1 and #3 with OBS set at 60 fps (you have to exit and restart OBS for the new setting to take effect). Results were 60 fps.


    CONCLUSION:

    My 120 fps camera has been re-encoded to run at the OBS rate. There is no setting to turn this off.

    As I said in earlier post, OBS can run at a maximum of 120 fps. So those of us with 120 fps cameras should be OK, just be sure to set OBS to 120 fps. Leaving OBS at the default 30 or 60 fps will result in your 120 fps camera being dumbed down to the lower rate.

    This data suggests there is no point running cameras faster than 120 fps...they will be dumbed down to at least 120 fps or lower depending on the OBS frame rate setting.

    Anyway, that consumed an hour of my life, I'm not sure it was worth it. Definitely exceeds my interest level but I had started it so thought I should try to finish. I'll leave it to others to confirm or deny these results (or figure out what any of it means if HT's results are correct where he says OBS is working at the faster rates above 120 fps).
    Use the fractional value, i have it set to 2000 fps waiting on new camera

    Comment


    • #17

      Comment


      • #18
        Hehe, I never looked at the fractional. Just assumed it was fractions of the 1-120. So the integer fps stops at 120 and the fractional goes forever? Craziness!

        That's good though. Let us know how it works out. The OBS screens and everything are running at whatever rate you set, it's not just the cameras. My laptop was max'ed out and became unresponsive at 154 fps with two 120 fps cameras and replay running full screen. My TGC computer max'ed out at 334 fps with the same conditions. Didn't look at how jittery the video was at that loading...just a quick fps limit test.
        Last edited by FaultyClubs; 02-03-2019, 04:32 AM.

        Comment


        • #19
          FaultyClubs Been working with OBS Dev of Replay Input. We got the issues worked out about fps, the plugin now writes directly to memory instead of being processed by OBS, we are working on getting a sound trigger put in. We already got a delay added similar to Kinovea. Any other suggestions to improve it will be greatly appreciated.

          Comment


          • #20
            htdumps what size lens did you get? I ordered 2 of these (https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1) which is the same as yours (from the same seller) it just has a nice case on it.

            The 2.1mm lens has the widest FOV, however I could have probably done a 2.8mm to pull in tighter. I am about 5-6 ft from one camera and about 7 from the other and a 2.1mm lens is a bit too wide of a FOV. Once I mount my cameras (waiting on a long USB cable) I'll post some pictures.

            Thank you for the write up and I do believe this is a very good, affordable solution!

            Comment


            • htdumps
              htdumps commented
              Editing a comment
              You can rotate the cameras then flip the image in OBS, Which changes the FOV to more vertical. Im really close to my cameras my room is only 13'x12', so I must have the 2.1mm.
              Last edited by htdumps; 02-05-2019, 10:40 PM.

          • #21
            HT: Sounds like you're on the case. Adding audio trigger is good OBS has the audio streams and understands Python so should be doable.

            An option to automatically save the replay buffer would be nice. OBS has no analysis capability but Kinovea does. Kinovea reads the OBS files just fine for downstream analysis.

            I'm seeing a bit of jitter in slow motion playback. Might be a replay source issue. Keep an eye out for that in your testing.

            Comment


            • htdumps
              htdumps commented
              Editing a comment
              Im using some alpha builds I'll let you know once he puts them up on git

          • #22
            Got audio trigger working, updated version of tutorial and plugin soon.

            Comment


            • #23
              Here's a video with my 2 live cams with a slow mo replay. This works better than I expected. Thanks htdumps. I am using the keyboard right now to trigger a slow mo replay, but I will probably setup a bluetooth headset + Voice Attack until those Alpha mods come through.

               

              Comment


            • #24
              Huge update. We now have sound detection and full fps playback with OBS and Replay source. This has been a huge amount of work on the developers part, if you like it please feel free to donate to him. He is very responsive and can tweak the plugin even more. paypal.me/exeldro

              Ok I'm going to assume you are somewhat comfortable with Obs, you can add camera inputs, and install plugins.

              Step 1 Installing Replay Source OBS

              1. Download from https://github.com/exeldro/obs-replay-source/releases

              2. Unzip the download in the 64 bit plugins folder for example: C:\Program Files (x86)\obs-studio\obs-plugins\64bit

              Step 2 OBS

              1. Create a new scene

              Step 3 OBS

              1. Add one video capture source name it DTL, make sure to adjust the camera and set it to highest fps

              2. Add an audio input source, name it MIC

              3. Add "ReplayInput" source, name it DTL slow, then select DTL and change the following values:
              Check Capture Internal Frame
              Select Your mic for the audio source.
              Duration 4000
              Load Delay 1000
              Maximum replays 1
              Speed Percentage change to your preference
              Threshold db change to how loud you need it so it will only capture the ball strike. I have it set to -11.00

              4. Click OK.


              Hit some balls.


              Here is an example: https://www.youtube.com/watch?v=S9IL0moAgJU
              Last edited by htdumps; 02-11-2019, 07:11 AM.

              Comment


              • htdumps
                htdumps commented
                Editing a comment
                Still testing will do a review soon.

              • davidK
                davidK commented
                Editing a comment
                Strong work.

                To open the Threshold db, I clicked Sound trigger load replay.

              • cweikert
                cweikert commented
                Editing a comment
                What do you mean by Step 3 OBS 3. Add "ReplayInput" source? Should there be an Option "ReplayInput" in the Dropdown-Menu from the +Sign? If there isn't one is there something wrong with my installation?

            • #25

              I lose my breath here. You don't have a day job ?
              Last edited by sorensen; 02-12-2019, 02:40 AM.

              Comment


              • htdumps
                htdumps commented
                Editing a comment
                Day job luckily is IT related

            • #26
              For anyone looking for a microphone to use with this, I liked this one (I used it with AZT and Kinovea). I lay it on the ground right next to my SkyTrak and it works great without being noticeable.

              Sony ECMCS3 Clip Style Omnidirectional Stereo Microphone, Silver
              https://smile.amazon.com/dp/B0058MJX..._VlKyCbY4Y377Z
              Last edited by jrz; 02-12-2019, 05:52 AM.

              Comment


              • #27
                Here Is a dual camera Slomotion Setup: https://youtu.be/pWOlpgoiyH0

                Comment


                • jrz
                  jrz commented
                  Editing a comment
                  Is that because you're trying to minimize the length of the recording of the ball? If so, is it safe to assume you can get them pretty close to synced?

                • htdumps
                  htdumps commented
                  Editing a comment
                  Yea you can get them to sync, it just takes time adjusting the length, load delay, and start delay.

                • NovaGolfer
                  NovaGolfer commented
                  Editing a comment
                  Can you tell me what camera you are using for the close up? I tried 640x480 @ 100fps, but it is wayyy to slow to capture the impact. Thanks in advance!

              • #28
                What's a good method to record last replay for export to Kinovea or similar?
                thanks

                Comment


                • FaultyClubs
                  FaultyClubs commented
                  Editing a comment
                  Assign a hot key to "save replay"

              • #29
                I'm not seeing a buffer file in the Videos folder. After hitting Ctrl-R and Ctrl-S I get two video files in that folder, but that's it. Am I missing something?

                Comment


                • FaultyClubs
                  FaultyClubs commented
                  Editing a comment
                  What's wrong with the files? I'd expect two files, one for each camera replay you saved. Kinovea opens them fine on my system.

              • #30
                Working getting a solution for Kinovea to record to a folder then OBS replay them at any speed you need,

                Comment

                Working...
                X