From 9d385b36fde14c1a13dbbef1a072496329d1659b Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Thu, 15 Apr 2021 19:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9Aslice=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=85=B3=E9=94=AE=E5=B8=A7=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Extension/H264.cpp b/src/Extension/H264.cpp index 04c638e1..1db1f676 100644 --- a/src/Extension/H264.cpp +++ b/src/Extension/H264.cpp @@ -181,17 +181,15 @@ void H264Track::inputFrame_l(const Frame::Ptr &frame){ _pps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize()); break; } - case H264Frame::NAL_IDR: { - insertConfigFrame(frame); - VideoTrack::inputFrame(frame); - break; - } case H264Frame::NAL_AUD: { //忽略AUD帧; break; } default: + if (frame->keyFrame()) { + insertConfigFrame(frame); + } VideoTrack::inputFrame(frame); break; } @@ -281,7 +279,8 @@ Sdp::Ptr H264Track::getSdp() { //////////////////////////////////////////////////////////////////////////////////////////////////// bool H264Frame::keyFrame() const { - return H264_TYPE(_buffer[_prefix_size]) == H264Frame::NAL_IDR; + //多slice 一帧的情况下检查 first_mb_in_slice 是否为0 表示其为一帧的开始 + return H264_TYPE(_buffer[_prefix_size]) == H264Frame::NAL_IDR && (_buffer[_prefix_size + 1] & 0x80); } bool H264Frame::configFrame() const {