Optimising OBS on a 2020 MacBook Pro
For the last few months (years, if I’m completely honest), I’ve been thinking about starting a YouTube channel. Nothing fancy, just a place to create the occasional map-making video or document my world-building session, that might one day graduate to a vlog of some form.
To reduce editing, I was thinking of streaming content directly to YouTube or Facebook from OBS. Since, OBS allows you to blend multiple video, audio and other sources and encode them live to a video stream or to disk, you can save a lot of editing time and overcome the limitations set by iMovie (such as only having two video sources). With a little know-how and a raster image editor like Photoshop, you can create all kinds of assets like overlays. Best of all, OBS is free and open source.
Unfortunately, the fly in my ointment is that I am a Mac user, and OBS isn’t optimised for Apple’s hardware out of the box. In fact, it’s so bad, any attempt to stream or record a 1080p feed at 60 FPS would bring my $3000 MacBook Pro to its knees. Somewhat deflated, I thought about investing in a secondary Windows PC to handle the OBS side, while leaving the Mac to do my content creation. I still may do that down the line, but stubbornly I set about to optimise OBS for my MacBook as much as I can to get me started — gear should never get in the way of creating content.
The MacBook Pro
For the record, my MacBook Pro is the last ever Intel model with a 10th generation 2 GHz i5 processor (4 cores, 8 threads), 16 GB of Ram, a 1 TB SSD. Baked into the CPU is an Intel Iris Plus GPU that can use up to 1536 MB of system RAM. I’m running Big Sur (macOS 11.5).
My MacBook Pro was the last model before the introduction of Apple Silicon, however, it also has an Apple T2 controller. I mention the T2 chip because this component can encode H.265 videos without touching the CPU. Unfortunately, OBS can’t stream using H.265, and I don’t think YouTube or Twitch accepts the codec for streaming, but we’ll return to the T2 chip later.
Attached to my MacBook Pro is a Belkin Thunderbolt 3 Pro dock, which I use to drive two monitors, a Logitech StreamCam, and connect my Mac to a gigabit LAN. I also have the option to add my older webcam (Logitech c920) to give me a secondary camera angle, should I need one. For the record, I’m on Australia’s National Broadband Network and I have an upload speed averaging between 35–37 Mbps.
I’m running OBS 27.0.1, the latest stable release at the time of writing (July 2021). This version introduced a raft of features for the Mac, including better support for Apple’s Video Toolbox APIs and Apple Silicon.
Before we get into the settings I use, let’s look at some low-hanging fruit of what can improve performance no matter what settings you use. Note that these work for me, with my metric being a reduction in CPU/GPU load. YMMV.
First off, don’t use OBS’s Auto-configuration wizard. For my Mac, it recommended software encoding (H265) with an output of no more than 720p at 60 FPS. I guess this would be fine if I was streaming games, but since I want to record my desktop, it’s too small for my needs. Moreover, using software encoding makes my Mac sound like a helicopter. We’ll apply our settings manually in a moment.
Secondly, if you are sharing your display or applications, avoiding doing so on a Retina or 4k display with a scaled resolution. When I moved my canvas to my 1440p display, I noticed a significant drop in CPU and GPU usage from when I had my canvas on a 4K display scaled to 1440p.
On this note, I observed it takes far fewer resources to capture the whole display (Display Capture), rather than a single application (Window Capture). I have no idea why this is the case, but I’m not curious enough to dig deeper.
Thirdly, disable the preview and don’t use Studio mode. Doing so means OBS isn’t rendering your output twice, and it saved me a tonne of CPU. Certainly, turn on the preview to composite your scenes, but before you hit record or stream, turn it off. If you need to see your stream, you can watch it on a secondary device, like an iPad.
Finally, if your camera or capture device supports it, switch to YUY2 from MJPEG or H264. Cameras using MJPEG and H.264 like the older Logitech c920 send a compressed video feed to your computer. While this sounds good, the feed must be decoded by the CPU before it can be used in OBS. Paradoxically, YUY2 streams, while much larger and require more bandwidth, need much less CPU processing to use.
Video (and a discussion about FPS)
For my base canvas resolution and output, I use 1920×1080 and set the downscale filter to Bicubic (Sharpened scaling, 16 samples).
As for FPS, well, that depends on what I’m doing. If I’m only recording, I can get away with 60 FPS. But, if I’m streaming I have to drop to 30 FPS otherwise the Mac drops lots of frames due to encoder lag, especially when I’m using an app like Pixelmator Pro that leans heavily on Apple’s Metal (GPU) framework.
In my case, I’m sharing my desktop and a camera feed, so 30 FPS is fine for my usage. If I was streaming gameplay and had to have 60 FPS, I’d drop the output to 720p. Even so, I suspect that if I was doing nothing but streaming with the Mac, for example capturing gameplay from a PS4 with a capture card, I suspect the computer might be just able to manage 1080p/60. However, I can’t verify that as I don’t own a capture card, and gaming is not my use case — at least at present.
Output — Streaming
For the Output streaming settings, the first thing to do is change the Output Mode to Advanced. This gives us a lot more control and is the only way on Mac to use the hardware encoder.
So, for the hardware encoder, I’m using the Apple VT H264 Hardware Encoder. In my 13-inch MacBook Pro, which doesn’t have a discreet GPU, this means OBS is using Intel’s QuickSync encoder built into the CPU. Unfortunately, that means it’s not using the T2 chip, since I believe that only supports H265 and as noted OBS doesn’t let you stream in H265.
I’ve set the bitrate to 6000 Kbps, but you are welcome to play around with this setting. Hardware encoders do better at higher bitrates, but you want to avoid going higher than your internet upload speeds can handle. For my machine/network/content, 6000 seems to be the sweet spot.
I also limit the bitrate and set 6000 as the maximum. Apple’s hardware encoder works on a variable bitrate (VBR), presumably to save file size, but most streaming services only support a constant bitrate (CBR).
Rounding out the streaming settings, I use a value of 1.5 for the Maximum bitrate window, 2 for keyframe interval, High for the Profile, and I use B-frames.
Performance is good, and I can stream 1080p30 with the CPU hovering about 8–10% (depending on the complexity of the scene). The MacBook Pro does get warm, but the fan speed isn’t too bad, and I typically drop less than 1% of the frames.
Output — Recording
I noted OBS doesn’t support H.265 for streaming, however, with a bit of digging around I discovered it does support the codec for recording. If you use OBS primarily for recording, this is a potential game-changer for those of us using Macs with a T2 chip, as you can offload the encoding, leaving your Intel CPU/GPU free to do other stuff.
But why would you use OBS for recording, not streaming? Well, it saves on editing afterwards. You can take advantage of OBS’s multiple sources, overlays, widgets, scene switching, and go ‘live to disk’ with your show. This means you don’t have to create your compositions in your video editing app, and if you only have iMovie, you’ll find yourself very limited as it only allows you to create two video sources. In my case, even my simple scene containing one camera feed, desktop capture and an overlay is impossible to make in iMovie.
To use the T2/H265 recording, you need to set the Type to Custom Output (FFmpeg), Container Format to MP4 or MKV, and the video encoder to hevc_videotoolbox.
Play around with the bitrate, noting that higher is better with hardware decoders, and you are no longer limited by your network bandwidth. Even with H.265 though, the higher the bitrate, the larger the file size you’ll have to deal with when you are finished.
The performance difference is staggering. Using these settings, I could comfortably record to 1080p 60 FPS with the CPU rarely moving above 4% and without dropping a single frame. And where Intel QuickSync raised the computer’s temps (and therefore fan speed), the T2/H.265 encoder kept the Mac cool with barely a whisper from the computer’s fans.
The only drawback is the output is an H.265 file, which isn’t as easy to work with as an H.264 file. While you can upload H.265 videos to YouTube, it’s not the preferred format. To overcome this limitation, you can convert your recording to H.264 using Handbrake, dropping the bitrate as needed before you upload the video to YouTube.
Generally, the streaming community sneer at Apple hardware, and until recently, I think it deserved the contempt it received. However, the latest version of OBS has done marvels to improve performance, by leveraging the Mac’s native hardware and Apple’s Videobox toolkit. While OBS is best on Windows PCs with Nvidia GPUs, I think streaming on Mac is a viable option for those of us with recent Intel models, even without a discreet GPU.
As an interesting postscript, most of the OBS’s advancements recently were to support Apple’s M1 Macs. As far as I’ve read, M1-enabled Macs are highly capable machines for streaming, and video work in general, and can work with both H.264 and H.265 at 4k (and higher) while barely warming above room temperature.
When I started my journey with streaming and OBS, I almost gave in and built a Windows machine, but at this point, I’m happy with what I can do, with the hardware I already own. If I had to buy a device for streaming today, I’d be more inclined to buy an M1 Mac mini.
Do you stream with an Intel Mac? If so, I’d love to hear about your experiences, and if you have ideas on how to improve my computer’s performance, I’d love to know!
Originally published at https://chrisrosser.net on July 24, 2021.