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

Nicolas George george at nsup.org
Mon Nov 10 14:18:25 CET 2014


Le nonidi 19 brumaire, an CCXXIII, Sylvester Zaluga a écrit :
> ***Sending again, this time with diff***

Better use git format-patch (or git send-email), so that you have authorship
and date information.

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

I will not actually oppose the feature, but every time people insist on
working with frame numbers instead of timestamp, I feel they are doing
something incorrectly.

In this particular case, you can easily work around the floating point
rounding issues, since the rounding behaviour of -force_key_frames is
specified: "more precisely at the first frames after each specified time".
You just have to make sure your timestamps are rounded down. For example,
with 24000/1001 FPS: 4.21 4.25 4.30* 4.34 4.38, you need to write 4.29, not
4.30, but you can also write any value between 4.25425 and the actual
4.295958333. (4.25+4.30)/2 = 4.275 should always work.

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

What happens if, in order to lower even more the SD bitrate, you decide to
add the decimate filter? Frame numbers are jumbled, while timestamps are
preserved. Working with frame numbers is fragile.

(Also, note that with some codecs, forcing a lot of keyframes will have a
dramatic effect on the efficiency of the encoding.)

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141110/000f31be/attachment.asc>


More information about the ffmpeg-devel mailing list