Question about bitrate under ffmpeg settings

byu

New Member
I have a question on the meaning of the field "Video Bitrate" under ffmpeg settings.

I have this PC with a magewell capture card deployed in the field that's recording videos everyday using OBS studio. The original setup was done by someone else long time ago, and they are using the following:

Container Format: mastroka
Video Bitrate: 10000 Kbps
Video Encoder Settings: -preset medium -tune film -crf 17

I want to ask what happens under the hood when they specify both a Video bitrate and a crf value? Is the software effectively doing
ffmpeg -i <input> -c:v libx264 -crf 17 -maxrate 10000K -bufsize ?? <output>
If so, what bufsize does OBS uses? or is it doing something else?

I've attached a screenshot of the settings page below. Thank you very much
obs-settings.png
 

koala

Active Member
Instead of trying to understand what the settings made by your predecessor actually do, try to find out what your predecessor tried to do, then do the right thing and configure OBS as it's meant to be configured.
Your predecessor wanted this:
  • configure settings for recording to a file
  • encoder x264
  • rate control crf with crf=17
  • set some presets and tuning for the x264 encoder
These are quite standard requirements and it's possible to enter them into the standard advanced settings (which is community supported) instead of custom output settings (which are not community supported due to their unlimited parameter combinations).
So do yourself a favor and configure this instead:
  • change type from "custom output (ffmpeg)" to standard
  • set video format to mkv
  • set video encoder to x264
  • set rate control to crf
  • set crf to 17
  • set cpu usage preset to medium
  • set profile to high
  • set tune to film
  • activate the same audio tracks that were activated in custom mode
  • remove any text from the x264 options and custom muxer settings text fields, in case some custom options appear
This will also answer your question about bitrate and crf: in crf rate control mode, there is no bitrate setting. And that's correct, because crf is a quality based rate control, no bitrate based rate control.
 

byu

New Member
Thanks for the reply. I should add more context. I wanted to understand how bitrate setting works because I have some lossless videos that I want to re-encode to simulate as if they were recorded with the PC, so I can run some tests that compares lossless videos vs videos recorded with our setup.

I've noticed that videos recorded with the PC have an average bitrate of slightly less than 10000kbps, and if I simply re-encode the lossless videos at crf 17 the average bitrate is over 40000kbps. These videos are medical procedures and they have similar levels of motion scenes.

I do agree with that going forward i should just use standard advanced settings.
 

koala

Active Member
Your videos encoded by OBS and with the options from your screenshot are 10000 kbps, because the option format is invalid. The given options are simply not applied, so what OBS actually uses is an implicit CBR rate control with bitrate 10000 kbps. This -crf 17 is ignored.

That's why one should not use ffmpeg output, because it's not intuitive to use. The correct parameter format is "keyword1=value1 keyword2=value2", not "-keyword1 value1 -keyword2 value2".
 

byu

New Member
that's good to know, thank you very much!

Do you know what bufsize is used when OBS is doing the constant bit rate control?
 

Suslik V

Active Member
To get full list of FFmpeg parameters that were used in the recorded file you can try "MediaInfo" util (there, under the Text view you will find string of the all encoding options that were used during encoding of the media file, the string itself in MediaInfo util is named Encoding settings).
 

byu

New Member
Thanks for the reply. It looks like videos recorded by OBS doesn't have the encoding settings saved
 

Suslik V

Active Member
I don't know - my saved. Example (see longest string in the middle):
Code:
...
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Stream size                              : 2.23 MiB
Writing library                          : x264 core 164 r3095 baee400
Encoding settings                        : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=3 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=10000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Default                                  : No
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
...
 

Suslik V

Active Member
the version of OBS was: 27.2.0-887-gf1cf3ff14 (64-bit, windows)

for OBS v30.0.2, bitrate set to 2500, it looks like this:
Code:
...
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 1.085
Writing library                          : x264 core 164 r3106 eaa68fa
Encoding settings                        : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=3 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=2500 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Default                                  : No
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
...

MediaInfo 17.10 (main menu View > Text). The media file to MediaInfo was added via drag-n-drop move from Q-Dir v11.44 file explorer.
 

koala

Active Member
These settings are visible only if the encoder is x264. Recordings with nvenc, probably other hardware encoders as well, don't contain this detailed info. But with x264, they should definitely be visible with MediaInfo.
 
Top