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

Michael Niedermayer michaelni
Mon Nov 2 23:18:45 CET 2009


On Mon, Nov 02, 2009 at 09:49:32PM +0000, declan harrison wrote:
> 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.

The ffmpeg API does support changing the bitrate, its just a field in
AVCodecContext after all.
Our ratecontrol code would blow up if you did that though, this should not
be hard to fix if someone wants to try ...


> 
> 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.

for h264 you of course need to pass that to libx264 then and need a libx264
that supports it
also our internal rc code isnt used in that code path so no need to change it
but i really would prefer if our internal code would support that too if
external libs do ...


> 
> 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
> set.
> 
> 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.

my gut feeling says that making the code support dealing with changing crf
would be nicer for the end user than reiniting the encoder

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091102/794c328e/attachment.pgp>



More information about the ffmpeg-devel mailing list