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() {