From adf0e09262bb814cb1faa362b65608bd6573d46b Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 6 Dec 2019 17:23:49 +0800 Subject: [PATCH] =?UTF-8?q?mp4=E7=82=B9=E6=92=AD=E6=94=AF=E6=8C=81pts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/MP4Reader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Record/MP4Reader.cpp b/src/Record/MP4Reader.cpp index 74521fd3..b082234d 100644 --- a/src/Record/MP4Reader.cpp +++ b/src/Record/MP4Reader.cpp @@ -219,7 +219,8 @@ inline bool MP4Reader::readVideoSample(int iTimeInc,bool justSeekSyncFrame) { for (; iIdx < iNextSample; iIdx++) { uint8_t *pBytes = _pcVideoSample.get(); uint32_t numBytes = _video_sample_max_size; - if(MP4ReadSample(_hMP4File, _video_trId, iIdx + 1, &pBytes, &numBytes,NULL,NULL,NULL,&_bSyncSample)){ + MP4Duration pRenderingOffset; + if(MP4ReadSample(_hMP4File, _video_trId, iIdx + 1, &pBytes, &numBytes,NULL,NULL,&pRenderingOffset,&_bSyncSample)){ if (!justSeekSyncFrame) { uint32_t iOffset = 0; while (iOffset < numBytes) { @@ -230,7 +231,8 @@ inline bool MP4Reader::readVideoSample(int iTimeInc,bool justSeekSyncFrame) { break; } memcpy(pBytes + iOffset, "\x0\x0\x0\x1", 4); - writeH264(pBytes + iOffset, iFrameLen + 4, (double) _video_ms * iIdx / _video_num_samples, 0); + uint32_t dts = (double) _video_ms * iIdx / _video_num_samples; + writeH264(pBytes + iOffset, iFrameLen + 4, dts, dts + pRenderingOffset / 90); iOffset += (iFrameLen + 4); } }else if(_bSyncSample){