[FFmpeg-devel] [PATCH] ffmpeg: Integrate two checks
Michael Niedermayer
michael at niedermayer.cc
Wed Jul 3 22:50:56 EEST 2019
On Mon, Jul 01, 2019 at 11:04:43PM +0200, Andreas Rheinhardt wrote:
> For audio packets with dts != AV_NOPTS_VALUE the dts the dts was
> converted twice to the muxer's timebase during streamcopy, once as a
> normal packet and once specifically as an audio packet. This has been
> changed.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> You are right. Seems that this is not covered by fate.
>
> fftools/ffmpeg.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 01f04103cf..f81b1b3983 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2044,20 +2044,19 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
> else
> opkt.pts = AV_NOPTS_VALUE;
>
> - if (pkt->dts == AV_NOPTS_VALUE)
> + if (pkt->dts == AV_NOPTS_VALUE) {
> opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
> - else
> - opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase);
> - opkt.dts -= ost_tb_start_time;
> -
> - if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) {
> + } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
> int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size);
> if(!duration)
> duration = ist->dec_ctx->frame_size;
> - opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts,
> - (AVRational){1, ist->dec_ctx->sample_rate}, duration, &ist->filter_in_rescale_delta_last,
> - ost->mux_timebase) - ost_tb_start_time;
> - }
> + opkt.dts = av_rescale_delta(ist->st->time_base, pkt->dts,
> + (AVRational){1, ist->dec_ctx->sample_rate}, duration,
> + &ist->filter_in_rescale_delta_last, ost->mux_timebase);
> + opkt.pts = opkt.dts - ost_tb_start_time;
this is ugly and confusing. As this introduces a difference betweem pts and dts
just because the adjustment for dts is factored out into a few lines later
> + } else
> + opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase);
> + opkt.dts -= ost_tb_start_time;
>
> opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190703/a4f6ee9a/attachment.sig>
More information about the ffmpeg-devel
mailing list