兼容时间戳不规范的H265流:#894

This commit is contained in:
ziyue 2021-06-15 12:55:55 +08:00
parent 24ab876fdb
commit 4d0db1b7c1
2 changed files with 17 additions and 5 deletions

View File

@ -169,10 +169,22 @@ bool FrameMerger::willFlush(const Frame::Ptr &frame) const{
//时间戳变化了 //时间戳变化了
return true; return true;
} }
if (frame->getCodecId() == CodecH264 && switch (frame->getCodecId()) {
H264_TYPE(frame->data()[frame->prefixSize()]) == H264Frame::NAL_B_P) { case CodecH264 : {
//如果是264的b/p帧那么也刷新输出 if (H264_TYPE(frame->data()[frame->prefixSize()]) == H264Frame::NAL_B_P) {
return true; //如果是264的b/p帧那么也刷新输出
return true;
}
break;
}
case CodecH265 : {
if (H265_TYPE(frame->data()[frame->prefixSize()]) == H265Frame::NAL_TRAIL_R) {
//如果是265的TRAIL_R帧那么也刷新输出
return true;
}
break;
}
default : break;
} }
return _frameCached.size() > kMaxFrameCacheSize; return _frameCached.size() > kMaxFrameCacheSize;
} }

View File

@ -169,7 +169,7 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
return; return;
} }
if(_lastPacket && _lastPacket->time_stamp != frame->dts()) { if (_lastPacket && (_lastPacket->time_stamp != frame->dts() || type == H265Frame::NAL_TRAIL_R)) {
RtmpCodec::inputRtmp(_lastPacket); RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr; _lastPacket = nullptr;
} }