[FFmpeg-devel] [Bugreport] and [Patch]: duration of TS streams is wrong when used near 2^33 wrap
Thorsten Jordan
tjordan
Mon Oct 29 11:23:32 CET 2007
Hello,
in libavformat/utils.c, the function av_estimate_timings_from_pts() is
used also for TS streams. It seeks to begin of file and gets a PTS value
from a stream's packet and one value from the end.
It then computes:
line 1559ff:
***snip***
...
end_time = pkt->pts;
duration = end_time - st->start_time;
if (duration > 0) {
...
***snap***
now for TS the PTS values are wrapping around at 2^33, so if the start
pts is near 2^33 and the end pts is beyond it, end < start is true
trivially, leading to no computed duration.
How to fix that?
e.g.: compute duration = (2^33 + end - start) & (2^33-1)
pro: works for this and similar files
con: would give still wrong values if the file is longer than 2^33 pts
(26.5 hours), but rare case
it would not hurt for PS streams, as for PS the PTS is max. 2^32 iirc.
The attached patch does that.
One problem remains: seeking in that file doesn't work for parts beyond
the 2^33 bareer, it falls back to positions before it, which is logical,
as the index seeker doesn't handles wrapping. Maybe one could store
continuous PTS values in the index tables then?
any comments welcome
--
Greetings, Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ts_duration_compute_fix.patch
Type: text/x-patch
Size: 737 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071029/e6354cd8/attachment.bin>
More information about the ffmpeg-devel
mailing list