X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mux.cpp;h=f52f795029c7ff3fd30daff5126244919de56def;hb=ad1641ad3ab50ecd17af2e1c2d980f26e6adf0bb;hp=5c6a150edd80e80e1e2825e6ab1d012f1a33253f;hpb=30a7d1923b360f993209426aff4d2ea76da794bc;p=nageru diff --git a/mux.cpp b/mux.cpp index 5c6a150..f52f795 100644 --- a/mux.cpp +++ b/mux.cpp @@ -145,7 +145,7 @@ Mux::~Mux() avformat_free_context(avctx); } -void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts) +void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational timebase) { AVPacket pkt_copy; if (av_copy_packet(&pkt_copy, &pkt) < 0) { @@ -153,13 +153,13 @@ void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts) exit(1); } if (pkt.stream_index == 0) { - pkt_copy.pts = av_rescale_q(pts, AVRational{1, TIMEBASE}, avstream_video->time_base); - pkt_copy.dts = av_rescale_q(dts, AVRational{1, TIMEBASE}, avstream_video->time_base); - pkt_copy.duration = av_rescale_q(pkt.duration, AVRational{1, 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) { - pkt_copy.pts = av_rescale_q(pts, AVRational{1, TIMEBASE}, avstream_audio->time_base); - pkt_copy.dts = av_rescale_q(dts, AVRational{1, TIMEBASE}, avstream_audio->time_base); - pkt_copy.duration = av_rescale_q(pkt.duration, AVRational{1, 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); }