[FFmpeg-devel] Enhance ffmpeg to expose libx264 option "repeat-headers" so that we can dynamically change video birate for H264

declan harrison harrison.declan
Mon Nov 2 22:49:32 CET 2009

Hi Guys

I have previously posted a related article on the ffmpeg-users and
xuggle-users mailing list to see if fthe fmpeg libraries API supports the
ability to dynamically change the encoding video bitrate real time for H264
codec from one value to another.  From this I realised that ffmpeg API
doesnt currently support this ability.

So my use case is a server program that decodes a HTTP video stream real
time and then re-encodes the video in the same container format but
typically to lower bit rate.  The video codec employed is H264 (using
libx264).  This works well for me using the ffmpeg libraries API currently.

I also needed the ability to change say after a short period of time to
change the "crf" value used for the encoder as the available bandwidth has
changed.  So initally I just changed the "crf" on the same coder but this
didnt work.

After some research I found that what I needed to do was to re-initialize
the x264 encoder and then ensure that the parameter "b_repeat_headers" is
always set. So re-initing the encoder inherently starts the stream at an IDR
frame, which will involve sending new SPS/PPS as long as b_repeat_headers is

libx264 does provide an option called "repeat-headers" that does just this,
however this option isnt exposed by ffmpeg. So I manually amended
ffmpeg/libx264 so that the parameter "b_repeat_headers" is set.  Once this
was done I was then able to dynamically change the video bitrate and other
quality affecting parameters using ffmpeg.

So I was wondering if you guys would suport a change that would allow ffmpeg
to expose this option just like they expose other libx264 options e.g.
"crf"?  Or would you recommend another approach to allow this to happen.  I
think other users would find this ability very useful.


More information about the ffmpeg-devel mailing list