In ffmpeg, how to search to a keyframe BEFORE a specified time?
For a video in the
flv container formats, I need to:
Get its duration.
Get a keyframe at 25% of its duration. If frame at 25% isn't a keyframe, seek to the first keyframe before that frame.
Seek to audio at 10ms before that keyframe.
According to the following comment on StackOverflow,
av_seek_frame seems to only seek to a keyframe after a specified time.
Given that it appears I can only seek after a specified time, how is it possible to get the required keyframe and to seek to the correct part in a
flv container as specified above?
My best bet is probably parsing the header (and index, where applicable) manually, and then use the
Or I can just walk the whole file, and just check if
AVFrame->key_frameis true or not.
It would be awesome if the
trim filter could support different seek methods, but I guess I have to get correct timestamps by myself, is that correct?