[FFmpeg-devel] [PATCH] avidec: Mark first frame as keyframeincase there are no keyframes.
donmoir at comcast.net
Wed Feb 1 02:02:17 CET 2012
>>>> This fixes seeking in filecopy.avi of Ticket504
>>> This doesn't seem right to me to handle at demuxer level.
>>> For example for an auto-generated index the demuxer will not even be
>>> able to do such a hack.
>>> It seems more sensible for me for the seeking function to validate the
>>> index and have some fallback behaviour if it does not make sense.
>> well, that would make seeking O(n) while its O(log n) ATM, we at least
>> have to validate during adding index entries
>> and iam not sure if doing this for non avi makes sense (cut mpg surely
>> can start with non keyframes)
> This might make sense:
> If the decoder->read_seek function has failed, go ahead in av_seek_frame
> after read_seek has failed and seek to the byte position of the first of
> the index_entries if there are any. If there are no index_entries, then
> seek to the byte position of whatever the first packet position would be
> for the stream which should be the same as the first of the index_entries
> if there are any.
> At this failure point, I don't think we care if the first frame is marked
> as a keyframe or not and the above seems reasonable. Initially there are
> some cases where there are no index_entries. Thats fine and normally these
> will be built as the file is read or when seeking.
> The thing about avformat_seek_file failing is you don't know why it failed
> internally. (log messages yes ,but these don't do you any good internally)
> It probably should only fail on more serious errors like a read error etc.
> This could also be controlled by another flag to state you want the above
> While handling this in av_seek_frame does not take care of
> av_index_search_timestamp failing, we pretty much know why that failed.
The other side of this is the first packet read should be reflected as a
keyframe so not sure if handling this only in av_seek_frame is sufficient.
Probably better to add a keyframe index point as the first index_entry.
More information about the ffmpeg-devel