[FFmpeg-devel] [PATCH] [RFC] libavformat/mpegts: Prevent wrapping of PTS & DTS

DeHackEd git at dehacked.net
Sun Jun 12 14:37:57 CEST 2016


On 06/12/2016 08:23 AM, Michael Niedermayer wrote:
> On Sat, Jun 11, 2016 at 06:55:32PM -0400, DeHackEd wrote:
>> Presently the mpegts demuxer passes the timestamps from received packets directly to the output AVPackets. 2^33 / 90000
>> seconds is about 26.5 hours at which point applications start having a fit, and that's assuming timestamps begin at time 0.
>>
>> So here's a first revision of a patch to fix that issue.
>>
>> Improvements possible:
>> * In its current form intended for continuous sources like over-the-air receivers and multicast sources. When used on
>> files there will be problems with seeking.
>> * Constants such as 2^33 could be turned into macros for readability
> 
>>  mpegts.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++--------
>>  1 file changed, 48 insertions(+), 8 deletions(-)
>> b95c5f58685106dab1f434a3bb465ad5a0ba1636  new-pts-dts.patch
>> From d06a3bd39fc4f01b9ce6132d80634dd31be7b1aa Mon Sep 17 00:00:00 2001
>> From: DHE <git at dehacked.net>
>> Date: Mon, 30 May 2016 18:31:43 -0400
>> Subject: [PATCH] libavformat/mpegts: Prevent wrapping of PTS & DTS
> 
> this could cause issues with seeking (as the same packet could
> result in different timestamps depending on luck) as well as subtitles
> (which could get misidentified as wraps)

Yes, I found that in testing. Unfortunately I don't know enough about ffmpeg to fix that myself at this time. It's a big
reason I'm posting this patch as [RFC].

> also mpeg-ps has the same kind of timestamps,
> If there is an issue that would affect it too, a fix should be in
> common code
> iam not sure what issue there is though, it seems you expect something
> from the demuxer that its not supposed to do.

I did it this way because 1) it's the issue I personally ran into, and 2) I was talking about it in #ffmpeg-devel and
was told "mpegts demuxer should handle the wrapping in itself and just output timestamps that are rising"[1], so I did.

> mpeg-ps/ts have 33bit timestamps and they wrap, anything done to
> the wraping belongs to the user applications or common code in
> libavformat.
> 
> If you want to remove timestamp discontinuities in libavformat properly
> or just wraps, thats more complex and will require keeping track of
> where the discontinuities are so that seeking around in the virtual
> continuous timeline works and is fully consistant
> 


--
[1] http://ffmpeg.gusari.org/irclogs/2016/05/30/ffmpeg-devel.log.20160530




More information about the ffmpeg-devel mailing list