]> git.sesse.net Git - nageru/commitdiff
Rescale the pts/dts properly in the MJPEG encoder (matters only if we switch mux...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 Feb 2019 22:30:49 +0000 (23:30 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 21 Feb 2019 22:30:49 +0000 (23:30 +0100)
nageru/mjpeg_encoder.cpp

index 8192be4cfa8e62e8fa6430ad211d740baaba393c..4ad0797c53f5f3e022e1869e2529ebdd2130e9f5 100644 (file)
@@ -336,7 +336,8 @@ void MJPEGEncoder::write_mjpeg_packet(int64_t pts, unsigned card_index, const ve
        pkt.size = jpeg.size();
        pkt.stream_index = card_index;
        pkt.flags = AV_PKT_FLAG_KEY;
-       pkt.pts = pkt.dts = pts;
+       AVRational time_base = avctx->streams[pkt.stream_index]->time_base;
+       pkt.pts = pkt.dts = av_rescale_q(pts, AVRational{ 1, TIMEBASE }, time_base);
 
        if (av_write_frame(avctx.get(), &pkt) < 0) {
                fprintf(stderr, "av_write_frame() failed\n");