From 1d132b59235286a19635096aca975e386a1c29fa Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Sun, 2 Jun 2019 00:43:29 +0400 Subject: [PATCH] When writing MP4 sample, save buffer.size() into a temporary variable before calling buffer.extract(). (#2628) --- src/zm_video.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zm_video.cpp b/src/zm_video.cpp index 07bedc683..309c507c0 100644 --- a/src/zm_video.cpp +++ b/src/zm_video.cpp @@ -101,7 +101,7 @@ X264MP4Writer::X264MP4Writer( Error("Failed init swscaleobj"); return; } - + swscaleobj.SetDefaults(zm_pf, codec_pf, width, height); /* Calculate the image sizes. We will need this for parameter checking */ @@ -458,11 +458,12 @@ int X264MP4Writer::x264encodeloop(bool bFlush) { /* Write the sample */ if ( !buffer.empty() ) { + unsigned int bufSize = buffer.size(); if ( !MP4WriteSample( mp4h, mp4vtid, - buffer.extract(buffer.size()), - buffer.size(), + buffer.extract(bufSize), + bufSize, duration, offset, prevKeyframe) ) {