[Ffmpeg-devel] Timestamp troubles
Steve Lhomme
steve.lhomme
Thu Mar 2 21:26:44 CET 2006
Michael Niedermayer wrote:
> Hi
>
> On Tue, Feb 21, 2006 at 02:07:44PM -1000, Steve Lhomme wrote:
>> Hi everyone,
>>
>> We're currently adding some kind of frame browsing in DrDivX OSS, using
>> (Dr)FFMPEG as the decoding engine. So far so good.
>>
>> But we also want to seek in the stream backward and forward. We use
>> av_seek_frame for that, with the video stream index we're looking for.
>>
>> The problem is that the timestamps of packets seem to be inconsistent.
>> Here are 2 cases to explain the situation :
>>
>> - goats.wmv:
>>
>> * timestamps in the AVStream.index_entries ranges from 1 to 78 (78s)
>
> fixed
Good, we made the same fix :)
>> * the AVFormatContext.duration is 78.866.000 (probably in ?s)
>> * AVStream.time_base is (1, 1.000)
>> * AVCodecContext.time_base is (1, 1.000)
>>
>>
>> So, it looks like the timestamp to give to av_seek_frame should be
>> between 1 and 78, that is the duration multiplied by both time bases. Or
>> it could just simply be the duration divided by AV_TIME_BASE (1.000.000).
>>
>>
>> - chems1.vob
>>
>> * timestamps in the AVStream.index_entries ranges from 3.484 to 1.601.884
>> * the AVFormatContext.duration is 17.760.000 (probably in ?s)
>> * AVStream.time_base is (1, 90.000)
>> * AVCodecContext.time_base is (25.025, 1.001)
>>
>> And in that case I have no idea how to translate a value in the
>> "duration" format to something that will match the value needed to look
>> in the index_entries.
>
> duration * 90000 / AV_TIME_BASE
I use the following to get a value to give to av_seek_frame:
ts_increment = av_rescale(SEEK_PERIOD_IN_SECONDS,
avctx->streams[vidTrackId]->time_base.den,
avctx->streams[vidTrackId]->time_base.num);
And it seems to work for many formats.
More information about the ffmpeg-devel
mailing list