8. Production: Optimising with OBS Studio
By Simon Baker, Technical Director and Digital Producer at Wise Children
The notes that follow are based on my experience of setting up OBS for TicketCo’s servers. They are a mix of trial and error, a lot of YouTube videos and forum searching. There are a myriad of OBS tutorials online and I recommend EposVox’s masterclass (just give him a search on YouTube).
This guide will help you optimise your settings and preferences, rather than teach you how to use OBS. TicketCo has a more introductory OBS guide found here if you need help getting started.
Always bear in mind that TicketCo will broadcast your video at a maximum frame size of 1080p and at a frame rate is 30fps.
How it works
OBS is an open source cross platform software for live streaming and recording, and it is largely referred to as OBS Studio. OBS essential encodes incoming captured video and audio data and transmits that data via Real Time Messaging Protocol (RMTP). This RMTP pipe or link is how you send your live stream to TicketCo’s servers. There are many alternatives to OBS, and if you are using an alternative, note that these setting can equally be applied there.
Most of the settings here are self explanatory. One thing to note is that right at the bottom of the screen are the settings for Multi view - this is useful if you are using OBS as your A/B switcher. Here you can set up what your multi view might look like.
Heres you can define what you will be outputting over your stream and recordings, and this is vital. First, change Output mode from Simple to Advanced in order to reveal the settings you need.
- Streaming tab: These are the settings for the live stream
- Audio Track: Here you can define which audio track will be broadcast. OBS has 6 stereo tracks available. You can only choose one, and for simplicity I make this Audio Track 1. This means that in sources I also need to assign any audio inputs to track 1.
- Encoder: Choose x264. This is better than the other options unless you have a very fast graphics card. If working on a Windows machine with an Nvidia graphics card, try NVENC. Experiment to see what gives you the best outcome for your setup.
- Enforce streaming service encoder options: This has no impact on a TicketCo stream.
- Rescale Output: You can choose to rescale your frame size, if, for example, you have set up to work in 1080p but only have internet speed to stream at 720p. Personally, I would do this in the Video settings further on.
- Rate Control: The options here are for which type of BitRate you want to you use. I always select CBR (Constant Bit Rate) as it is the most straightforward for streaming.
- Bitrate (this is key!): Here you need to balance how fast your internet connection truly is against the quality of your stream. Bit rate refers to the quality of your stream being uploaded or transmitted. If you have an upload speed of 10Mbps, then theoretically the maximum speed you could stream at is 10,000 kbps; however, this does not work in practise. You need to leave some space for network fluctuation and some headroom for audio. So, plan to use only 70% of your true bandwidth. For a 1080p HD frame running at 25 or 30fps I would set my bitrate to 6000kps. That means having a steady 10Mbps broadband connection per stream.
- Custom Buffer Size: I leave this unticked.
- KeyFrame Interval: I set this to 2 rather than “auto”. KeyFrame is another vital setting that often gets forgotten. A KeyFrame is a fully rendered frame image in a video, whereas subsequent frames/delta frames actually contain the information that has changed. For broadcasting, the KeyFrame interval used to be set at 10, but for live streaming 2 is much better. This is due to the user experience. Remember, a viewer can’t start watching from a delta frame, only a KeyFrame, as that is the frame that has all the information. So if a viewer watching your stream moves out of wifi range and jumps onto another network with a slower download speed, they could only join again at the next KeyFrame. If this was set to 10 they would have to wait 10 seconds, whilst at 2, you only wait 2 seconds.
- CPU Usage Preset: This is the preset for the OBS x264 Encoder - I leave mine set at "Fast" which seems to work fine.
- Profile: I’d opt for "High" or "Main" as it forces a better encode, but switch to "None" if you notice frames dropping.
- Tune: "None" works most of the time, but you may need to fine tune.
- X246 options: You can really start to fine tune the stream with custom coding but this would take a much longer guide and probably me not writing it.
This is only important if you plan to record your stream either for later Video On Demand work or as a reference.
- Type: I leave mine in standard.
- Recording Path: Browse to define where the recording will be stored.
- Recording format: Set to "MKV" and change later (this is only the container rather than the file type).
- Audio track: You probably only need 1 unless you have split up certain bits of audio (e.g. maybe you have recorded the coms channel for reference, or you have an audio description for later use).
- Encoder: I leave at x264.
- Rescale output: I try and record the native canvas.
- Rate Control: Opt for "CQP" or "CRF" as these will give a higher quality recording, but they will also increase your file sizes. I use CRF at 16.
- KeyFrame: Interval of 2
- CPU: Superfast
You need to test your settings at this stage in order to put your unique setup under a load - hit Streaming and Recording together and see what happens to the GPU/CPU and see how OBS is handling frame rates. Try some test streams to YouTube, for example. Everything is a fine balance, so test everything - a lot. The above is what works for me today on my 2017 iMacPro, with iOS 10.15.7 and OBS 26.0.2, but as we all know, lots can change in an update.
I set this at "320" (by trade, I’m a sound designer and can’t bear the thought that we’d use anything less!). Now head over to the Audio tab on the left.
- General: Set your sample rate - this is normally 48K.
- Channels: The TicketCo stream is "Stereo".
- Global Audio Devices: On the Mac version, you can define some global audio inputs; however, you can also add audio devices into your sources selection. All audio devices appear in the audio mixer page regardless.
- Meters: This is up to personal preference.
- Monitoring: I set this to be my interface so it’s another point I can plug my headphones in.
- Hotkeys: I don’t use this feature.
Here you define your frame sizes and your default frame rate.
- Base (Canvas Resolution): I set this to 1920 x 1080 as that what my switcher is set to.
- Output (Scaled Resolution): You could reduce your streaming/recording output here but I set this to the same as the base rate. If you were streaming with some difficulty and dropping frames, an idea might be to reduce your output size and this is a good place to do it. In that case, you would reduce to 1280 x 720.
- Downscale Filter: This is a personal choice but I opt for "Bicubic". It is worth trying options based on your own set up and material.
- FPS: I use 25fps, but remember the maximum fps at TicketCo is 30.
Here you can define keyboard shortcuts. I use either a Stream Deck to control OBS or, even better, there is a great bit of software called Companion made by Bitfocus which allows you to emulate Stream Deck buttons to control Blackmagic Switchers/OBS etc.
There are some differences between the Mac and PC options here.
- Colour Format: On the Mac I use NV12.
- Colour Space: 709.
- Colour Range: Partial, unless you’re seeing a mismatch in colours - it’s worth experimenting with this as it will depend on your capture cards.
- Recording details: This is up to you.
- Stream delay: I don’t use this. Between sending a stream and seeing it on TicketCo’s servers, there can be a lag of up to 40s. Adding more has never seemed worth it.
- Automatically Reconnect: I have this on its default.
- Bind to IP: I set this to the network adapter I know has the main broadband line, so I can be certain I’m sending down the right Cat5 port and not jumping to the Wifi port at random.
- Dynamically change bit rate: This feels scary to me but maybe worth try if your internet isn’t stable.
- Service: Custom.
- Server: Copy and paste the RTMP URL from the TicketCo Technical information page. This is unique for each stream.
- Stream Key: Copy and paste as above.
Remember, you only get the stream information from TicketCo 1 hour prior to broadcast. You can test during this hour as the viewer at home will still only see the TicketCo countdown clock until the stream goes live at the advertised time.
Things to watch in OBS as you go live
Make sure you have the Status Bar enabled in Views. At the very bottom of the application window you’ll see a green box meaning the steam is healthy. A yellow box means the stream is becoming congested and you might start dropping frames, and red means trouble and generally means your internet isn’t coping.
You should also see the CPU usage and the frame rate. Your frame rate should be static - it is common to drop a few frames when first connecting, but aside from that you need your frame rate to be solid. I also open the Stats window (View > Stats). This, alongside the TicketCo Stream health tab will give you a lot of information when you need to troubleshoot.
If the frame rate is jumping around, then you need to establish if this is due to your graphics card or due to the stream not uploading quickly enough. It may also be worth having a GPU monitor open so you can see directly what is happening. If the problem is a graphics card issue, there are a few things to consider, and all depend on your specific set up. It could be due to too many sources trying to render simultaneously, through to the GPU getting too hot after a busy day of tech.
If there is a problem at the network end, you’ll also see the bitrate fluctuating in the Stats window (and you’ll see it on the TicketCo Stream health window). 9 times out of 10 this is due to some kind of bandwidth restriction local to you. Running a speed test is a good idea and checking your upload speed is healthy. It is rare for the issue to be at the TicketCo/AWS end.
One thing to try, is to rescale the frame size to 720p, drop the bit rate and see if that stabilises everything. If it does, then this would point to an unreliable local broadband connection or network connection somewhere.
Video takes far longer to process than audio, which means the sound happens first followed by the picture. This makes the sound to picture out of sync, and you need to delay the sound back to the picture. You do this by adding time to the sound.
There are number of ways to do this, and the amount of latency will vary greatly depending on various factors (what cameras, what cable type, what frame rate, what capture card). To re-sync video to sound you often need delays of 40 to 50ms.
You really need to “add time” at the final stage of delivery (adding time too early in the signal path can just cause more issues and get more confusing). I try and add time at the final stage in OBS. You do this by clicking the little cog icon on your master audio interface in the Audio Mixer window, then select Advanced Properties. Here you can view things like volume, pan and stereo/mono switching. Crucially, you can also assign your input to one of OBS’s tracks and better still, you’ll see the sync offset.
Note you can only monitor and hear any changes you make to the sync offset by listening to an active stream or recording playback. This means setting an offset delay is more time consuming than you’d think. I suggest the following:
- Try downloading this video from Ballastmedia here. This will give you a short video with a bouncing ball animation. The ball hits and clicks at zero time i.e. in perfect sync.
- You then need to play back this video from a laptop or tablet, and record it back into OBS using one of your cameras and a radio mic going via your broadcast set up. You are going to point one of the cameras (going via your switcher) at a laptop screen, rest a radio mic onto of the laptop (going via your console and processing back into your audio capture method) and hit record on OBS. It’s really important to do this using your signal flow.
- When you have that recorded, you need to demux and export the video and load it into a DAW.
- When you playback the file, you’ll see that the ball bouncing, and the sound of the click, are out of sync.
- Look at the click wave form, and you’ll see its transient peak - the distance in time between that peak, and the ball hitting centre on screen is your sync delay. Handily, the video clip has a line marked in ms and a little rectangle icon running across the top in time with the clip. If you use the cursor in your DAW, and line this up to the transient peak, the video clip will be in the correct place and that little rectangle will give you the offset in ms.
- Take this figure and add it to the sync offset in OBS and you should now be in sync. You should repeat this process to make sure you’ve done it correctly. This time the ball and click should align on playback!
This methods takes into account any time correction that’s been added to the sound system. Remember that having the perfect sync will make all the difference to your audience.