From 5f6bcec4ca42baf69f0402d312f99a858e8b843d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Jan 2019 11:35:37 -0500 Subject: [PATCH] Use start_pts instead of start_dts when calculating output pkt.dts. Because start_dts is often lower than start_pts, we can get into a situation where we calculate a dts that is > pts. --- src/zm_videostore.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 6d728cf3c..e28ce6b59 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -815,34 +815,38 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) { } // Just because the in stream wraps, doesn't mean the out needs to. Really, if we are limiting ourselves to 10min segments I can't imagine every wrapping in the out. So need to handle in wrap, without causing out wrap. if ( ipkt->dts != AV_NOPTS_VALUE ) { +#if 0 if ( (!video_first_dts) && ( ipkt->dts >= 0 ) ) { // This is the first packet. opkt.dts = 0; Debug(1, "Starting video first_dts will become (%" PRId64 ")", ipkt->dts); video_first_dts = ipkt->dts; } else { +#endif opkt.dts = av_rescale_q( - ipkt->dts - video_first_dts, + ipkt->dts - video_first_pts, video_in_stream->time_base, video_out_stream->time_base ); - Debug(3, "opkt.dts = %" PRId64 " from ipkt.dts(%" PRId64 ") - first_dts(%" PRId64 ")", - opkt.dts, ipkt->dts, video_first_dts); + Debug(3, "opkt.dts = %" PRId64 " from ipkt.dts(%" PRId64 ") - first_pts(%" PRId64 ")", + opkt.dts, ipkt->dts, video_first_pts); video_last_dts = ipkt->dts; +#if 0 } - } else { - Debug(3, "opkt.dts = undef"); - opkt.dts = AV_NOPTS_VALUE; - } - - if ( opkt.dts > opkt.pts ) { - Debug(1, +#endif + if ( opkt.dts > opkt.pts ) { + Debug(1, "opkt.dts(%" PRId64 ") must be <= opkt.pts(%" PRId64 "). Decompression must happen " "before presentation.", opkt.dts, opkt.pts); - opkt.dts = opkt.pts; + opkt.dts = opkt.pts; + } + } else { + Debug(3, "opkt.dts = undef"); + opkt.dts = 0; } + opkt.flags = ipkt->flags; opkt.pos = -1; opkt.data = ipkt->data;