[FFmpeg-cvslog] lavf/segment: fix DTS inconsistencies with -reset_timestamps

Stefano Sabatini git at videolan.org
Wed Feb 6 22:56:58 CET 2013


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Wed Feb  6 00:19:52 2013 +0100| [b3d2c6f8b9d0ff577a5a32ad5ae417b8b3523317] | committer: Stefano Sabatini

lavf/segment: fix DTS inconsistencies with -reset_timestamps

The DTS needs to be resynched against the segment start PTS, or the
resulting DTS may result < PTS.

Reported-by: Owen Jones <riots6 at gmail.com>

See thread:
Subject: [FFmpeg-user] pts/dts error using reset_timestamps while splitting a DVD
Date: Sat, 19 Jan 2013 08:58:27 +0000

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3d2c6f8b9d0ff577a5a32ad5ae417b8b3523317
---

 libavformat/segment.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 4ae2019..13d8c43 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -42,7 +42,7 @@
 typedef struct SegmentListEntry {
     int index;
     double start_time, end_time;
-    int64_t start_pts, start_dts;
+    int64_t start_pts;
     char filename[1024];
     struct SegmentListEntry *next;
 } SegmentListEntry;
@@ -664,8 +664,6 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
         seg->cur_entry.index = seg->segment_idx;
         seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base);
         seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
-        seg->cur_entry.start_dts = pkt->dts != AV_NOPTS_VALUE ?
-            av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q) : seg->cur_entry.start_pts;
     } else if (pkt->pts != AV_NOPTS_VALUE) {
         seg->cur_entry.end_time =
             FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base));
@@ -679,18 +677,17 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (seg->reset_timestamps) {
-        av_log(s, AV_LOG_DEBUG, "stream:%d start_pts_time:%s pts:%s pts_time:%s start_dts_time:%s dts:%s dts_time:%s",
+        av_log(s, AV_LOG_DEBUG, "stream:%d start_pts_time:%s pts:%s pts_time:%s dts:%s dts_time:%s",
                pkt->stream_index,
                av_ts2timestr(seg->cur_entry.start_pts, &AV_TIME_BASE_Q),
                av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
-               av_ts2timestr(seg->cur_entry.start_dts, &AV_TIME_BASE_Q),
                av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
 
         /* compute new timestamps */
         if (pkt->pts != AV_NOPTS_VALUE)
             pkt->pts -= av_rescale_q(seg->cur_entry.start_pts, AV_TIME_BASE_Q, st->time_base);
         if (pkt->dts != AV_NOPTS_VALUE)
-            pkt->dts -= av_rescale_q(seg->cur_entry.start_dts, AV_TIME_BASE_Q, st->time_base);
+            pkt->dts -= av_rescale_q(seg->cur_entry.start_pts, AV_TIME_BASE_Q, st->time_base);
 
         av_log(s, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
                av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),



More information about the ffmpeg-cvslog mailing list