[FFmpeg-devel] [PATCH] Implemented arrange feature to convert from low timebase formats to high timebase
Michael Niedermayer
michaelni at gmx.at
Wed Oct 17 16:56:41 CEST 2012
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.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121017/36533311/attachment.asc>
More information about the ffmpeg-devel
mailing list