From 4d0db1b7c172ce2745007787bc00a72dc0ea0575 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Tue, 15 Jun 2021 12:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=E4=B8=8D=E8=A7=84=E8=8C=83=E7=9A=84H265=E6=B5=81=EF=BC=9A#894?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/Frame.cpp | 20 ++++++++++++++++---- src/Extension/H265Rtmp.cpp | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index e67eab47..db5272a9 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -169,10 +169,22 @@ bool FrameMerger::willFlush(const Frame::Ptr &frame) const{ //时间戳变化了 return true; } - if (frame->getCodecId() == CodecH264 && - H264_TYPE(frame->data()[frame->prefixSize()]) == H264Frame::NAL_B_P) { - //如果是264的b/p帧,那么也刷新输出 - return true; + switch (frame->getCodecId()) { + case CodecH264 : { + if (H264_TYPE(frame->data()[frame->prefixSize()]) == H264Frame::NAL_B_P) { + //如果是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; } diff --git a/src/Extension/H265Rtmp.cpp b/src/Extension/H265Rtmp.cpp index b3ae4fa9..3a8c32ab 100644 --- a/src/Extension/H265Rtmp.cpp +++ b/src/Extension/H265Rtmp.cpp @@ -169,7 +169,7 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) { return; } - if(_lastPacket && _lastPacket->time_stamp != frame->dts()) { + if (_lastPacket && (_lastPacket->time_stamp != frame->dts() || type == H265Frame::NAL_TRAIL_R)) { RtmpCodec::inputRtmp(_lastPacket); _lastPacket = nullptr; }