[FFmpeg-devel] [PATCH] Modified force_key_frames option to accept frame numbers

Sylvester Zaluga sylvester.zaluga at gmail.com
Mon Nov 10 00:30:36 CET 2014

Attached a patch which allows for passing in frame numbers
at which key frames should be forced. 

The current modes in which force_key_frames operate are:

* force_key_frames 1,2,3,4,5  - parameter is interpreted as timestamps
* force_key_frames expr:gte(t,n_forced) - parameter is an expression

The patch adds support for third mode:
* force_key_frames n:0,25,50,75,100  - interpret parameter as frame numbers

I find this useful for avoiding float precision-related
issues that surface when key frames are forced at specified timestamps.

My use case is as follows:
* generate output video with settings for HD video
* extract key frame numbers from HD video
* generate SD video with key frames at identical positions
* In my application, do video LODing by switching HD/SD video 
  depending on available bandwith

For generating the SD video I was using force_key_frames with timestamps,
but every-so-often a key frame would be forced too early.

The same behaviour could be achieved with an expression, for example:


This, however, is suboptimal, and not very clean. Additionally, there is
a size limit for expressions, so it can not be used for longer videos.

Please let me know any feedback you have on this patch or the approach used.

Sylwester Zaluga

Signed-off-by: Sylwester Zaluga <sylwekzff at outlook.com>

More information about the ffmpeg-devel mailing list