From 3429690d75cb0702eec6255bf0ec661d59f27bdd Mon Sep 17 00:00:00 2001 From: xgj Date: Thu, 17 Jun 2021 19:26:58 +0800 Subject: [PATCH] for h264 pps sps aud sei not check first_mb_in_slice --- src/Extension/Frame.cpp | 3 ++- src/Extension/H264Rtmp.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index 61b6d613..5864908b 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -191,7 +191,8 @@ bool FrameMerger::willFlush(const Frame::Ptr &frame) const{ } switch (frame->getCodecId()) { case CodecH264 : { - if (frame->data()[frame->prefixSize()+1]&0x80 !=0) { + auto type = H264_TYPE(frame->data()[frame->prefixSize()]); + if (frame->data()[frame->prefixSize()+1]&0x80 !=0 && type >=H264Frame::NAL_B_P && type<=H264Frame::NAL_IDR ) {// sei aud pps sps 不判断 //264 新一帧的开始,刷新输出 return true; }else{ diff --git a/src/Extension/H264Rtmp.cpp b/src/Extension/H264Rtmp.cpp index 19152a6f..47f5192e 100644 --- a/src/Extension/H264Rtmp.cpp +++ b/src/Extension/H264Rtmp.cpp @@ -183,7 +183,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { } } - if(_lastPacket && (_lastPacket->time_stamp != frame->dts() || pcData[1]&0x80 != 0)) { + if(_lastPacket && (_lastPacket->time_stamp != frame->dts() || (pcData[1]&0x80 != 0 && type>=H264Frame::NAL_B_P && type<=H264Frame::NAL_IDR))) { RtmpCodec::inputRtmp(_lastPacket); _lastPacket = nullptr; }