Opened 8 years ago

Last modified 8 years ago

#3827 new enhancement

Provide an option to quickly seek by a number of frames

Reported by: Ridley Combs Owned by:
Priority: wish Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


There are some cases where a user has the start and end frame numbers for their desired transcode, but not the corresponding timestamps. It'd be convenient to have an option analogous to -ss (as an input option) that skipped to the given frame number.
As most formats don't have frame numbers, this would require the file to be read all the way up to the seek point to count frames, but shouldn't necessitate *decoding* video until the first keyframe before the seek point. This would likely involve reading up to the given frame, then acting as if -ss was given with that frame's timestamp (i.e. index-seek to nearest keyframe, then insert trim filters).

Change History (5)

comment:1 by Clément Bœsch, 8 years ago

avformat_seek_file() has an almost unused flag called AVSEEK_FLAG_FRAME that could be used for this purpose if implemented properly. Subtitles use that (see ff_subtitles_queue_seek()) because they actually have a complete index. Assuming we do an index-pass, that might be realizable with some demuxers supporting the load of that index.

Note that your proposed method would work only if 1 packet = 1 video frame, which AFAIK is not always true.

comment:2 by Carl Eugen Hoyos, 8 years ago

What's wrong with the select filter?

in reply to:  2 comment:3 by Clément Bœsch, 8 years ago

Replying to cehoyos:

What's wrong with the select filter?


comment:4 by gjdfgh, 8 years ago

Cc: added

Seeking to an exact frame number is impossible (edit: without decoding the file from the start), unless the file format has a complete index.

But API extensions to know _if_ the index is complete and frame exact, and the ability to use it, would be nice.

Last edited 8 years ago by gjdfgh (previous) (diff)

comment:5 by Carl Eugen Hoyos, 8 years ago

Component: ffmpegundetermined
Note: See TracTickets for help on using tickets.