[FFmpeg-devel] [PATCH] ffmpeg: implement -force_key_frames_expr option

Stefano Sabatini stefasab at gmail.com
Sat Dec 15 10:57:27 CET 2012


On date Friday 2012-12-14 20:35:36 +0100, Michael Niedermayer encoded:
> On Fri, Dec 14, 2012 at 06:02:11PM +0100, Stefano Sabatini wrote:
> > On date Friday 2012-12-14 03:15:22 +0100, Michael Niedermayer encoded:
> > > On Fri, Dec 14, 2012 at 12:56:42AM +0100, Stefano Sabatini wrote:
> > [...]
> > > > +The expression in @var{expr} can contain the following constants:
> > > > + at table @option
> > > > + at item n
> > > > +the number of already forced keyframes
> > > > + at item prev_t
> > > > +the time of the last forced key frame, it is @code{NAN} when no
> > > > +keyframe was forced yet
> > > > + at end table
> > > 
> > > implementing this in ffmpeg.c makes the expression evaluation only
> > > available to ffmpeg and not to other user applications, also the
> > > expression evaluator only has a small number of input variables
> > > available from the application.
> > 
> > > in libavcodec it would have a much larger amount of information
> > > available, like the scene change score or various rate control
> > > parameters
> > 
> > The idea is interesting. How do you want it to be implemented? This
> > patch only computes the next value to force when the current frame is
> > forced, an alternative could be to evaluate an expression (say:
> > "gte(t, n*10-0.05)") at each frame (slower but more flexible).
> 
> yes, i think per frame evaluation is better

Now the problem is that I can't set frame->key_frame in
avcodec_encode_video2(), since the struct is const. The best way seems
to set a field in AVCodecContext.force_key_frame, but that would
require changing all the encoders.

Do you see a better way?
-- 
FFmpeg = Fancy & Fundamentalist Mournful Picky Enhancing Gorilla


More information about the ffmpeg-devel mailing list