VideoToolbox h.264 Encoder: CBR Possible?

Hey folks -

I'm a bit clueless about this specific topic, so bear with me please. I make use of the recording/streaming app called OBS Studio on both my Windows and Mac rigs. OBS supports hardware encoding to h.264 for recording and streaming so that you don't have to lean on its internal FFMpeg calls to transcode for you. Big CPU saver there.

I note when I'm attempting to stream to YouTube, for instance, that YT reports back that I'm sending all sorts of wonky bitrates. OBS lets me set a "bitrate" and "bitrate limit", which I have to 50Mbit/sec. YouTube will randomly report back that I'm sending it 70Mbit/sec. Or 90+ Mbit/sec. This is brief, but it happens repeatedly.

Challenge: streaming services hate VBR. And according to the OBS devs I've talked to, they seem to think that Apple's VT encoders only support VBR. Is that true? Is there any way to force CBR so that my Mac only ever sends 50Mbit/sec, no more, no less?

Thanks.

Replies

Does OBS set the kVTCompressionPropertyKey_DataRateLimits encoding session property?

Using that property is the proper way to set an hard limit on the bitrate.

  • Based in the code, it appears to.

    code = session_set_prop( session, kVTCompressionPropertyKey_DataRateLimits, rate_control);

Add a Comment

I've spent quite a while trying to figure out what was breaking my streams with red herring dropped network frames. The major stream platforms do not like variable bitrates, and according to people in OBS support (supported by various anecdotes in OBS' forum) the Apple Hardware Encoder will only work in ABR mode, not CBR. This basically means you that using the Apple 264 Hardware Encoder in OBS (29.0.2 at time of writing) is not suitable for purposes of live streaming on Intel-based macs.

[CBR for Apple H264 Hardware encoder was merged in OBS 28 for Apple Silicon]https://github.com/obsproject/obs-studio/pull/6668), but it seems there is no solution for Intel-based macs.

The support people in the OBS discord told me this has never worked properly, and probably wont be fixed for Intel macs.