[FFmpeg-devel] [PATCH] lavf/concatdec: fix timestamp conversion

Nicolas George george at nsup.org
Tue Nov 18 20:30:21 CET 2014


L'octidi 28 brumaire, an CCXXIII, Stefano Sabatini a écrit :
> 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);

Normally, ist->time_base and ost->time_base should be the same. Can you
explain the circumstances where this is needed?

>      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;
>  }

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141118/2fb1fe13/attachment.asc>


More information about the ffmpeg-devel mailing list