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

Michael Niedermayer michael at niedermayer.cc
Sun Jun 12 15:40:48 CEST 2016


On Sun, Jun 12, 2016 at 08:31:45AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Sun, Jun 12, 2016 at 8:23 AM, Michael Niedermayer <michael at niedermayer.cc
> > 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)
> 
> 
> How does that work before the patch?

timestamp discontnuities are handled in ffmpeg*c, which removes them
for formats which can contain discontnuities.

The pts_wrap code in libavformat can be disabled by the user
if its not disabled it will remove the wrap closest to the start
time. So this fixes the wrap issue for which contain only 1 wrap
without introducing any inconsistencies and working timestamp based
seeking

one certainly could add an array listing IO positions and
discontnuities, and use that to reasonably consistently remove the
discontnuities.
Especially the timestamp based seeking code (which basically does
a form of bisection) would fall apart if the timestamps are randomly
unwraped whie bisecting
some list of unwrap points, should make timestamp based seeking with
multiple wraps work if its applied to the timestamps between demuxer
and seek code and the "index cache" is flushed or updated if the
discontnuities are changed


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160612/5524b2de/attachment.sig>


More information about the ffmpeg-devel mailing list