[FFmpeg-devel] [PATCH] lavf/concatdec: fix timestamp conversion
Stefano Sabatini
stefasab at gmail.com
Tue Nov 18 11:39:12 CET 2014
Use the correct output time base when converting.
---
libavformat/concatdec.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index f275bac..2574e0b 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -480,7 +480,7 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
int ret;
int64_t delta;
ConcatStream *cs;
- AVStream *st;
+ AVStream *ist, *ost;
while (1) {
ret = av_read_frame(cat->avf, pkt);
@@ -506,22 +506,23 @@ static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
if ((ret = filter_packet(avf, cs, pkt)))
return ret;
- st = cat->avf->streams[pkt->stream_index];
- av_log(avf, AV_LOG_DEBUG, "file:%li stream:%d pts:%s pts_time:%s dts:%s dts_time:%s",
+ ist = cat->avf->streams[pkt->stream_index];
+ ost = avf ->streams[pkt->stream_index];
+ av_log(avf, AV_LOG_DEBUG, "file:%li stream:%d pts:%s pts_time:%s dts:%s dts_time:%s time_base:%d/%d",
cat->cur_file - cat->files, pkt->stream_index,
- av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
- av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
+ av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->time_base),
+ av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->time_base), ist->time_base.num, ist->time_base.den);
+ av_packet_rescale_ts(pkt, ist->time_base, ost->time_base);
delta = av_rescale_q(cat->cur_file->start_time - cat->avf->start_time,
- AV_TIME_BASE_Q,
- cat->avf->streams[pkt->stream_index]->time_base);
+ AV_TIME_BASE_Q, ost->time_base);
if (pkt->pts != AV_NOPTS_VALUE)
pkt->pts += delta;
if (pkt->dts != AV_NOPTS_VALUE)
pkt->dts += delta;
- av_log(avf, 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),
- av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
+ av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s time_base:%d/%d\n",
+ av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->time_base),
+ av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->time_base), ost->time_base.num, ost->time_base.den);
return ret;
}
--
1.8.3.2
More information about the ffmpeg-devel
mailing list