From 52480717e3a929c5b67753f277839156dfd950d5 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Thu, 4 Feb 2021 18:13:33 +0800 Subject: [PATCH] =?UTF-8?q?p=E5=B8=A7=E6=97=B6=E9=97=B4=E6=88=B3=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=97=B6=E7=A1=AE=E4=BF=9Drtmp=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8:#724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264Rtmp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Extension/H264Rtmp.cpp b/src/Extension/H264Rtmp.cpp index 97981343..88e926b2 100644 --- a/src/Extension/H264Rtmp.cpp +++ b/src/Extension/H264Rtmp.cpp @@ -185,7 +185,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { } } - if(_lastPacket && _lastPacket->time_stamp != frame->dts()) { + if(_lastPacket && (_lastPacket->time_stamp != frame->dts() || type == H264Frame::NAL_B_P)) { RtmpCodec::inputRtmp(_lastPacket); _lastPacket = nullptr; } @@ -216,6 +216,10 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { _lastPacket->buffer.append((char *) &size, 4); _lastPacket->buffer.append(pcData, iLen); _lastPacket->body_size = _lastPacket->buffer.size(); + if (type == H264Frame::NAL_B_P) { + RtmpCodec::inputRtmp(_lastPacket); + _lastPacket = nullptr; + } } void H264RtmpEncoder::makeVideoConfigPkt() {