Opened 3 years ago

Last modified 3 years ago

#3827 new enhancement

Provide an option to quickly seek by a number of frames

Reported by: 11rcombs Owned by:
Priority: wish Component: undetermined
Version: git-master Keywords:
Cc: nfxjfg@googlemail.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

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 Changed 3 years ago by ubitux

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 follow-up: Changed 3 years ago by cehoyos

What's wrong with the select filter?

comment:3 in reply to: ↑ 2 Changed 3 years ago by ubitux

Replying to cehoyos:

What's wrong with the select filter?

"quickly"

comment:4 Changed 3 years ago by gjdfgh

  • Cc nfxjfg@googlemail.com 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 3 years ago by gjdfgh (previous) (diff)

comment:5 Changed 3 years ago by cehoyos

  • Component changed from ffmpeg to undetermined
Note: See TracTickets for help on using tickets.