I have been playing around with FFMPEG and I am trying to achieve a streaming bitrate that is as constant as possible. I have gone through the FFMPEG documentation and examples, but when I measure the resulting bitrate with wireshark I still do not get a constant bit rate and I see perdiodic bit rate peaks that go over the -maxrate parameter.

Currently I take in the RTSP stream from an IP cam and then transcode it to a local UDP stream using the following command (or variations of it):

ffmpeg -rtsp_transport tcp -i "RTSP_IP" -an -c:v libx264 -x264-params "hal-hrd=cbr:force-cfr1" -b:v 100k -minrate 100k -maxrate 100k -bufsize 150k -threads 1 -flush_packets 0 -f mpegts "udp://@"

In the above example I am striving for a max bit rate of 100Kbps but I still see bit rate spikes whose amplitude is affected by the -bufsize parameter. However, making the bufsize too small makes the image quality be readjusted too often. The resulting wireshark graph is:


Three questions:

  1. Is there there something that I am doing wrong here? - No matter what I do I always see peaks going over the -maxrate
  2. My understanding is that FFMPEG performs a soft-cap on the bit rate. Is this correct?
  3. How can I achieve a hard cap on the bit rate?

Thanks for any help you can provide on the matter. I have been banging my head on this problem for a while now so I will really appreciate it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.