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

Michael Niedermayer michaelni at gmx.at
Sat Dec 15 19:18:59 CET 2012


On Sat, Dec 15, 2012 at 10:57:27AM +0100, Stefano Sabatini wrote:
> 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?

the keyframe expression evaluation could be put in a seperate function
and called from mpegvideo or other encoders for which it makes sense.
You cant call it from the generic code anyway as it doesnt know the
scene change score and other parameters from motion estimation and
rate control which may be interresting.

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121215/fc646d52/attachment.asc>


More information about the ffmpeg-devel mailing list