diff options
author | Nicola Murino <nicola.murino@gmail.com> | 2017-09-23 17:14:03 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-10-19 16:01:25 +0200 |
commit | e87c20d325eaf9e6813c46654292d68f8b9bc521 (patch) | |
tree | c7fa147ed066fe5dc17b230caf19ab08d8909498 | |
parent | 326c74123d969a7ea0eccbfdef5fa45ce68076ad (diff) | |
download | gst-libav-e87c20d325eaf9e6813c46654292d68f8b9bc521.tar.gz |
avdemux: reset to 0 negative pts
for us pts are unsigned so reset to 0 negative pts returned from libav.
This is better than outputs completly wrong timestamps
https://bugzilla.gnome.org/show_bug.cgi?id=787795
-rw-r--r-- | ext/libav/gstavdemux.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/libav/gstavdemux.c b/ext/libav/gstavdemux.c index c119798..3728705 100644 --- a/ext/libav/gstavdemux.c +++ b/ext/libav/gstavdemux.c @@ -1394,6 +1394,7 @@ gst_ffmpegdemux_loop (GstFFMpegDemux * demux) gint outsize; gboolean rawvideo; GstFlowReturn stream_last_flow; + gint64 pts; /* open file if we didn't so already */ if (!demux->opened) @@ -1421,7 +1422,21 @@ gst_ffmpegdemux_loop (GstFFMpegDemux * demux) /* do timestamps, we do this first so that we can know when we * stepped over the segment stop position. */ - timestamp = gst_ffmpeg_time_ff_to_gst (pkt.pts, avstream->time_base); + pts = pkt.pts; + if (G_UNLIKELY (pts < 0)) { + /* some streams have pts such this: + * 0 + * -2 + * -1 + * 1 + * + * we reset pts to 0 since for us timestamp are unsigned + */ + GST_WARNING_OBJECT (demux, + "negative pts detected: %" G_GINT64_FORMAT " resetting to 0", pts); + pts = 0; + } + timestamp = gst_ffmpeg_time_ff_to_gst (pts, avstream->time_base); if (GST_CLOCK_TIME_IS_VALID (timestamp)) { stream->last_ts = timestamp; } |