New submission from Daryll Strauss <[EMAIL PROTECTED]>:

ffmpeg uses av_estimate_timings_from_pts to calculate the duration of MPEG
streams. It does this by reading the first packet in each stream and then it
reads near the end of the file to find the last packet in each stream and
subtracts the pts values for the two packets.

There are two problems with the code as it stands. First, when it jumps to the
end it stops reading packets with the first near-the-end packet it encounters.
it should stop with the last near-the-end packet. This can cause a substantial
difference in the duration values.

The second problem is that taking the last time stamp minus the first time stamp
actually leaves you off by one. You need to add the duration of the packet the
packet itself to the value to that duration. To do that I've modified the code
to read the first 2 packets in each stream and calculate a packet duration for
each stream from those packets. That packet duration is added in to the final
stream duration.

Attached is a replacement for the av_estimate_timings_from_pts routine which
correctly calculates duration. Now duration*frame rate = numbers of frames in
the stream as it should.

I have no SVN access, so if someone with write access can insert this, that
would be great.

----------
files: ffmpeg.fix
messages: 629
nosy: daryll
priority: important
status: new
substatus: new
title: Stream durations wrong in MPEG
type: patch

______________________________________________________
FFmpeg issue tracker <[EMAIL PROTECTED]>
<https://roundup.mplayerhq.hu/roundup/ffmpeg/issue175>
______________________________________________________

Attachment: ffmpeg.fix
Description: Binary data

Reply via email to