From: Steinar H. Gunderson Date: Thu, 21 Feb 2019 22:30:49 +0000 (+0100) Subject: Rescale the pts/dts properly in the MJPEG encoder (matters only if we switch mux... X-Git-Tag: 1.8.3~30 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=55797f91bcb5ff2b45a1a8961ffe92a4c7f98763 Rescale the pts/dts properly in the MJPEG encoder (matters only if we switch mux away from mp4). --- diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 8192be4..4ad0797 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -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");