p帧时间戳异常时确保rtmp播放正常:#724

This commit is contained in:
xia-chu 2021-02-04 18:13:33 +08:00
parent 34bbfc8bcb
commit 52480717e3

View File

@ -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); RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr; _lastPacket = nullptr;
} }
@ -216,6 +216,10 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_lastPacket->buffer.append((char *) &size, 4); _lastPacket->buffer.append((char *) &size, 4);
_lastPacket->buffer.append(pcData, iLen); _lastPacket->buffer.append(pcData, iLen);
_lastPacket->body_size = _lastPacket->buffer.size(); _lastPacket->body_size = _lastPacket->buffer.size();
if (type == H264Frame::NAL_B_P) {
RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr;
}
} }
void H264RtmpEncoder::makeVideoConfigPkt() { void H264RtmpEncoder::makeVideoConfigPkt() {