[FFmpeg-devel] [PATCH] Implemented arrange feature to convert from low timebase formats to high timebase
Roman Arutyunyan
arutyunyan.roman at gmail.com
Wed Oct 17 17:14:07 CEST 2012
2012/10/17 Michael Niedermayer <michaelni at gmx.at>
> On Wed, Oct 17, 2012 at 11:34:58AM +0400, Roman Arutyunyan wrote:
> [...]
> > AVRational av_codec_get_pkt_timebase (const AVCodecContext
> *avctx);
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index 05c4b7f..0b59eeb 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -3498,6 +3498,14 @@ static int compute_pkt_fields2(AVFormatContext
> *s, AVStream *st, AVPacket *pkt){
> > if(pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
> delay==0)
> > pkt->pts= pkt->dts;
> >
> > + if (st->codec->arrange_threshold && pkt->dts != AV_NOPTS_VALUE &&
> st->pts.val != AV_NOPTS_VALUE){
> > + int64_t diff = pkt->dts - st->pts.val;
> > + int64_t maxdiff = av_rescale(st->codec->arrange_threshold,
> st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);
> > + av_dlog(s, "Arrange dts=%"PRId64" cur_dts=%"PRId64"
> diff=%"PRId64" maxdiff=%"PRId64"\n", pkt->dts, st->pts.val, diff, maxdiff);
> > + if (diff > -maxdiff && diff < maxdiff)
> > + pkt->dts = pkt->pts = AV_NOPTS_VALUE;
> > + }
>
> this doesnt look correct. The correction should be done where the
> problem is currently introduced. As done here , ffmpeg.c would send
> some timestamps to the muxer but the muxer would use different
> timestamps. its ffmpeg*.c or a common utility function used by
> ffmpeg*.c where the correction should be done.
>
> Currently timestamps are rounded toward "nearest", what should
> instead be done, is to round toward the exact duration + last_time
> see av_get_audio_frame_duration() to find the exact frame duration.
>
I'm absolutely agree with you. The reason why I've done that way is there's
nothing
that looks like last_time on earlier stages of frame processing (ffmpeg.c).
I can either use st->pts.val which seems no good because it looks like
accessing
internal data of output stream from outside (or am I wrong with that?).
Another way is copying code from compute_pkt_fields2 (missing pts case)
which does what you say - calls av_get_audio_frame_duration, accumulates
pts etc. I'll fix that, thanks for your comment.
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The worst form of inequality is to try to make unequal things equal.
> -- Aristotle
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
More information about the ffmpeg-devel
mailing list