fftools/ffmpeg: Integrate two checks

For audio packets with dts != AV_NOPTS_VALUEs 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@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Andreas Rheinhardt 2019-10-12 05:18:39 +02:00 committed by Michael Niedermayer
parent 568d62117d
commit 13dc90396d
1 changed files with 10 additions and 10 deletions

View File

@ -2048,20 +2048,20 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
if (pkt->pts != AV_NOPTS_VALUE) if (pkt->pts != AV_NOPTS_VALUE)
opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time; opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time;
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); opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
else } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
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) {
int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size); int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size);
if(!duration) if(!duration)
duration = ist->dec_ctx->frame_size; duration = ist->dec_ctx->frame_size;
opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts, 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, (AVRational){1, ist->dec_ctx->sample_rate}, duration,
ost->mux_timebase) - ost_tb_start_time; &ist->filter_in_rescale_delta_last, ost->mux_timebase);
} /* dts will be set immediately afterwards to what pts is now */
opkt.pts = opkt.dts - ost_tb_start_time;
} 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); opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);