From 892734bfd83aaef726b6d772c9e97a217a87e698 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 2 Aug 2019 11:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MediaFile/MP4Muxer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MediaFile/MP4Muxer.cpp b/src/MediaFile/MP4Muxer.cpp index cedc7c4f..076cc86c 100644 --- a/src/MediaFile/MP4Muxer.cpp +++ b/src/MediaFile/MP4Muxer.cpp @@ -79,11 +79,13 @@ void MP4Muxer::onTrackFrame(const Frame::Ptr &frame) { return; } - if(frame->getTrackType() == TrackVideo){ - if(!_started && !frame->keyFrame()){ - //第一帧必须是I帧,防止花屏 + if(!_started){ + //还没开始 + if(frame->getTrackType() != TrackVideo || !frame->keyFrame()){ + //如果首帧是音频或者是视频但是不是i帧,那么不能开始写文件 return; } + //开始写文件 _started = true; }