av_seek_frame() without AVSEEK_FLAG_ANY on mpg files returns success without seeking to a keyframe
|Reported by:||mbradshaw||Owned by:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
Description (last modified by )
The documentation of
av_seek_frame() makes a contract that it seeks to a keyframe if
AVSEEK_FLAG_ANY is not set. mpg files break this contract by not seeking to a keyframe and still returning success.
It seems that any
AVInputFormat that doesn't have it's own
read_seek2() functions defined will default to either
ff_gen_search() (with priority given to
ff_seek_frame_binary() doesn't respect seeking by keyframe, and will break the keyframe contract made by
AVSEEK_FLAG_ANY is not set.
Seeking in mpg should require
AVSEEK_FLAG_ANY to be set in order for success to be returned (return failure if it's not specified). This can be done by requiring
AVSEEK_FLAG_ANY to be set before calling
2) (in response to Don's suggestions)
ff_seek_frame_binary() so that it respects seeking by keyframe if
AVSEEK_FLAG_ANY is not set. This can be done by sequentially reading (either forwards or backwards (I would prefer backwards)) up to a keyframe after the binary search is complete.
For context on how this came about, see this thread: http://ffmpeg.org/pipermail/libav-user/2012-July/002468.html
I originally opened ticket #1575 but Don Moir pointed out this is more of a bug than a lack of documentation.