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

declan harrison harrison.declan
Tue Nov 3 11:32:58 CET 2009


Hi Michael

See my replies inline.

Thanks

>
> > 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 ...
>
>
What I meant is that changing the bitrate parameter (which can be done)
after a period of time doesnt actually make a difference to encoding the
content when using libx264.  So even though we can amend these values it
doesnt have any effect as the encoder just uses the value that we initally
set the encoder up with.



>
> >
> > 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 ...
>
>
>
When I talk of changing the bit rate here what I really mean is to change
the quality setting which I typically do by setting a "crf" value that is
then used by libx264.


> >
> > 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
>
>
> To be able to change the  "crf" value or any other quality effecting rate
control for libx264 we need to be able to tell the x264 encoder by passing
the newly updated headers. x264 does allow to this happen by the setting of
the "repeat-headers" option.  This option isnt exposed currently by ffmpeg
but would be useful to many developers if it was, IMO.

What is the process if I want to request a change to the ffmpeg product
itself to support this change.  I can provide the code to do this if needed
but I need the developers to buy into this change.

Declan

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>



More information about the ffmpeg-devel mailing list