X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmjpeg_encoder.cpp;h=3f98cd0662a5e5be7eaec3240b6f267b3e8635e5;hb=b626186bffe85f4eeb135861bd02b752aa9001da;hp=8192be4cfa8e62e8fa6430ad211d740baaba393c;hpb=a000a60dff370ed7e5e8ed9f959cec6ec10d158f;p=nageru diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 8192be4..3f98cd0 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -208,6 +208,7 @@ void MJPEGEncoder::stop() running = false; should_quit = true; any_frames_to_be_encoded.notify_all(); + any_frames_encoding.notify_all(); encoder_thread.join(); if (va_dpy != nullptr) { va_receiver_thread.join(); @@ -336,7 +337,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");