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://@10.100.3.30:5004?packet_size=1316&bitrate=100000"
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:
- Is there there something that I am doing wrong here? - No matter what I do I always see peaks going over the -maxrate
- My understanding is that FFMPEG performs a soft-cap on the bit rate. Is this correct?
- 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!