So, you want to learn more about video encoding? How to set up your stream for the best quality given your computer’s hardware and connection limitations? Let’s start with this video by Tom Scott.
He does a great job of giving a quick primer on how video encoding works, and you will hopefully have a better understanding of the topics and terminology that we’ll be going over. All done? Great! Let’s get started.
Before we get into the details, let me explain what this guide is not. This is not intended to be a fully detailed technical explanation of how x264 works; there are far better guides out there than what I can provide here. If you’re interested in the nitty-gritty, head over to the doom9 forums, FFmpeg docs, or the x264 website and start digging. This is also not intended to be a “best settings” guide, and I will not recommend any specific settings. This is intended to help you understand how video encoding in general works, and how to better identify potential issues with your settings and help you learn where to look to correct them.
Let me reiterate that there is no such thing as “best settings”. Every single setup, for every single use case, will be different. As an example, I have 3 different sets of streaming encoding settings for the types of media I stream. One for fast motion games, one for desktop applications, and another for live video. If you are new to OBS or streaming in general, OBS Studio contains a feature known as the “Auto-Configuration Wizard” which can be found in the Tools menu. This tool will test your system and your internet connection to determine what it can handle from both an encoding standpoint and a connection stability standpoint. However, the best way to find your best settings is to test, test, and test again.
This guide is focused entirely on streaming with the x264 encoder. This is what the vast majority of OBS users will be using when they stream. For local recordings, your choice of encoder is far less relevant than your actual settings and in many cases a hardware encoder will be better suited for you. You can learn more about local recording settings in this guide here: http://obsproject.com/forum/resources/obs-studio-high-quality-recording-and-multiple-audio-tracks.221/
It is important to understand that video encoding is a very resource intensive process, especially when attempting to do so in real-time. Hardware encoders – such as Nvidia NVENC, Intel QuickSync, or AMD VCE – can help with this as they use special hardware in your system dedicated to the task of video encoding. As a trade-off the overall quality per bitrate is lower than the CPU-based x264 in nearly all cases. For streaming where bitrate is usually a constraining factor, x264 is currently the best option for getting the most quality out of your stream.
Only been in recent years have standard consumer-grade computers reached the point where they can realistically provide the processing power to do live video encoding. Keep all this in mind when you wonder why your 8 year old dual core Pentium CPU cannot encode 1080p 60fps without failing miserably. Even the most powerful consumer CPUs can still struggle with the load of encoding a high-resolution, high-fps stream.
x264 has several CPU presets, in increasing order from low CPU usage to high CPU usage: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo.
By “preset”, it means exactly what it sounds like: a set of pre-determined settings for x264 so that you don’t have to set them all manually yourself to tweak things. These sets of settings have been tested by lots of people and are great for general use, depending on what you want to get out of your encoder. The actual details of what the settings are can be found here: http://dev.beandog.org/x264_preset_reference.html
The basic idea is that, all things being equal (same bitrate, etc), less CPU usage would result in worse quality, and more CPU usage would result in better quality, because the presets change how much time the encoder spends compressing each frame to look good within its setting constraints. Sometimes you need to reduce your CPU usage in order to get good performance, and the higher CPU usage presets can be difficult to use effectively with average consumer CPUs.
The last thing to note is that any preset lower than medium will have significant diminishing returns, and is not really worth the extra CPU cycles for streaming scenarios. Unless you are squinting at two identical streams side by side, you will not notice a difference. That said, if your CPU can handle it, there’s no reason (outside your power bills) not to use them.
Here we have put together some comparison examples for how this actually looks in practice.
- x264, 1920×1080, 60fps, 2500kbps bitrate, high-detail low-motion scene:
- x264, 1920×1080, 60fps, 2500kbps bitrate, high-motion scene:
All these test are performed with exactly the same source video and bitrate, only the preset has changed.
However, it’s important to note that all of this assumes that your PC can handle the preset and resolution/fps that you are trying to encode. If it cannot, you might start to notice skipping or image distortion on your stream, accompanied by the message in OBS stating: Encoding overloaded! The simple way of fixing this issue is to turn down the resolution and FPS of your stream to reduce the load, and failing that, you may need to turn down the preset. You can check our detailed guide on how to troubleshoot encoding issues here: https://obsproject.com/wiki/General-Performance-and-Encoding-Issues
The amount of energy the CPU spends compressing each frame isn’t the only factor in video quality. Bitrate is also important, as it determines how much information you can put into each frame of video. If you are allowed to cram more data into each frame, you don’t need lots of CPU spent on compression, so you can make each frame look better just by cranking up the bitrate. Remember how the Tom Scott video looked when he simulated lowering bitrate, with all other settings left the same? The same is true the other way. If you increase bitrate, you can make the video look better quality.
Thus, you can get a good-looking video with relatively low CPU usage by using a low-CPU usage preset (like superfast) with a higher bitrate. Just note that the amount of bitrate you’ll need for this can vary greatly depending on the resolution and FPS you are trying to stream at. A 1080p 60fps stream at only 4000kbps bitrate using the ultrafast preset is not going to look very good. For reference, the YouTube encoding settings list is a great place to start. The list below differs slightly, and would be my personal recommendation as a starting point.
|853×480||800 – 1200 kbps||30|
|1024×576||1000 – 3000 kbps||30|
|1280×720||3000 – 5000 kbps||30|
|1920×1080||5000 – 8000 kbps||30|
|2560×1440||8000 – 12000 kbps||30|
|3840×2160||12000 – 20000 kbps||30|
They are assuming x264 encoder with the veryfast preset, and low to medium motion in your scene. For 1080p 60fps in a high-motion scenario (like an action or FPS game), you would likely need more than 8,000kbps of bitrate at veryfast for it to look smooth during playback. Conversely, low-motion video (such as an RTS game or streaming Photoshop art creation) can work with much lower bitrate. These charts are intended to give you an idea on where to start.
The end result of using a lower encoder preset and upping the bitrate will probably look a bit different then comparable bitrate at higher presets, but the goal is to get roughly the same quality by trading off CPU usage for bandwidth. I recommend trying both and see which one works for you in terms of quality, CPU usage, and what your connection and streaming service can handle.
For comparison, here is the same scene encoded using x264 veryfast in both a low-motion high-detail scene, and a high-motion scene.
- x264, 1920×1080, 60fps, veryfast preset, high-detail low-motion scene:
- x264, 1920×1080, 60fps, veryfast preset, high-motion scene:
As before with the preset test, these tests were performed with the exact same source video and preset, only the bitrate has changed.
I hope that this has helped you gain a better understanding of the basics on how video encoding works, the importance of bitrate, and the overall impact of changing these settings in OBS will have on your stream and performance of your PC. I will say again, the road to finding the perfect settings for your stream is to test, test, and test again. If you have any further questions, our forums and support chat are always open.
- Tom Scott video: https://www.youtube.com/embed/r6Rp-uo6HmI
- Advanced recording guide: http://obsproject.com/forum/resources/obs-studio-high-quality-recording-and-multiple-audio-tracks.221/
- x264 preset reference: http://dev.beandog.org/x264_preset_reference.html
- Doom9 (x264) forums: https://forum.doom9.org/
- FFmpeg wiki: https://trac.ffmpeg.org/wiki/Encode/H.264
- Official x264 website: https://www.videolan.org/developers/x264.html
- Official OBS wiki: https://obsproject.com/wiki/