From: Steinar H. Gunderson Date: Sat, 7 Apr 2018 21:11:28 +0000 (+0200) Subject: Revert "Simplify the timebase conversion in mux.cpp." X-Git-Tag: 1.7.2~44 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7d061eb7c72417a7783c8007531f7a9d4cd649d1;p=nageru Revert "Simplify the timebase conversion in mux.cpp." We should use the pts and dts from the function parameters, not from the packet. Would cause all wrong durations in some cases. This reverts commit bcaf94e7f9a10925a86b8f7e03e5e184550ae9f5. --- diff --git a/mux.cpp b/mux.cpp index e554ec5..5e9043e 100644 --- a/mux.cpp +++ b/mux.cpp @@ -154,9 +154,13 @@ void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational t exit(1); } if (pkt.stream_index == 0) { - av_packet_rescale_ts(&pkt_copy, timebase, avstream_video->time_base); + pkt_copy.pts = av_rescale_q(pts, timebase, avstream_video->time_base); + pkt_copy.dts = av_rescale_q(dts, timebase, avstream_video->time_base); + pkt_copy.duration = av_rescale_q(pkt.duration, timebase, avstream_video->time_base); } else if (pkt.stream_index == 1) { - av_packet_rescale_ts(&pkt_copy, timebase, avstream_audio->time_base); + pkt_copy.pts = av_rescale_q(pts, timebase, avstream_audio->time_base); + pkt_copy.dts = av_rescale_q(dts, timebase, avstream_audio->time_base); + pkt_copy.duration = av_rescale_q(pkt.duration, timebase, avstream_audio->time_base); } else { assert(false); }