From 29fcf3eb3b50d21a92f033546609989ca705fd5f Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 30 Aug 2020 09:15:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/MP4Muxer.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Record/MP4Muxer.cpp b/src/Record/MP4Muxer.cpp index af350f67..72fbbc9d 100644 --- a/src/Record/MP4Muxer.cpp +++ b/src/Record/MP4Muxer.cpp @@ -48,17 +48,13 @@ void MP4Muxer::inputFrame(const Frame::Ptr &frame) { } if (!_started) { - //还没开始 - if (!_have_video) { - _started = true; - } else { - if (frame->getTrackType() != TrackVideo || !frame->keyFrame()) { - //如果首帧是音频或者是视频但是不是i帧,那么不能开始写文件 - return; - } - //开始写文件 - _started = true; + //该逻辑确保含有视频时,第一帧为关键帧 + if (_have_video && !frame->keyFrame()) { + //含有视频,但是不是关键帧,那么前面的帧丢弃 + return; } + //开始写文件 + _started = true; } //mp4文件时间戳需要从0开始