From e12875fdff863cdd3cb5abe984bc42c0833f86e6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 18 Jun 2025 10:00:40 -0400 Subject: [PATCH] Remove code to do decode before encode. It cannot work, we have no idea what the state of the decoder is. Fix use of packet->in_frame->pts for video_last_pts. in_frame might be null and is likely in the wrong time_base --- src/zm_videostore.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 042864be9..de443dba3 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -1171,20 +1171,8 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr zm_packet) video_out_ctx->height ); } else if (!zm_packet->in_frame) { - Debug(4, "Have no in_frame"); - if (zm_packet->packet->size and !zm_packet->decoded) { - Debug(4, "Decoding"); - if (!zm_packet->decode(video_in_ctx)) { - Debug(2, "unable to decode yet."); - return 0; - } - // Go straight to out frame - swscale.Convert(zm_packet->in_frame.get(), out_frame); - } else { - Error("Have neither in_frame or image in packet %d!", - zm_packet->image_index); - return 0; - } // end if has packet or image + Error("Have neither in_frame or image in packet %d!", zm_packet->image_index); + return 0; } else { // Have in_frame.... may need to convert it to out_frame swscale.Convert(zm_packet->in_frame.get(), zm_packet->out_frame.get()); @@ -1278,9 +1266,11 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr zm_packet) video_out_stream->time_base.den); if (video_last_pts != AV_NOPTS_VALUE) { - opkt->duration = opkt->pts - video_last_pts; + opkt->duration = opkt->pts - video_last_pts; + Debug(1, "Duration %" PRId64 " from pts %" PRId64 " - last %" PRId64, opkt->duration, opkt->pts, video_last_pts); + if (opkt->duration < 0) opkt->duration = 0; } - video_last_pts = zm_packet->in_frame->pts; + video_last_pts = opkt->pts; write_packet(opkt.get(), video_out_stream); } // end while receive_packet } else { // Passthrough