From c31b0cc26b83c54f80f5b1ee6577e4274ba53881 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 16 Jul 2020 16:26:13 +0800 Subject: [PATCH] =?UTF-8?q?H264Track=E4=B8=8D=E8=BF=87=E6=BB=A4SEI:=20#411?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264.h | 5 ----- src/Extension/H264Rtmp.cpp | 7 +++---- src/Record/MP4Muxer.cpp | 8 +++++++- src/Record/TsMuxer.cpp | 8 +++++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Extension/H264.h b/src/Extension/H264.h index 1d890af0..a7fca526 100644 --- a/src/Extension/H264.h +++ b/src/Extension/H264.h @@ -228,11 +228,6 @@ private: } break; - case H264Frame::NAL_SEI:{ - //忽略SEI - break; - } - default: VideoTrack::inputFrame(frame); break; diff --git a/src/Extension/H264Rtmp.cpp b/src/Extension/H264Rtmp.cpp index 53ecef62..798de496 100644 --- a/src/Extension/H264Rtmp.cpp +++ b/src/Extension/H264Rtmp.cpp @@ -166,6 +166,9 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { auto pcData = frame->data() + frame->prefixSize(); auto iLen = frame->size() - frame->prefixSize(); auto type = H264_TYPE(((uint8_t*)pcData)[0]); + if(type == H264Frame::NAL_SEI){ + return; + } if (!_gotSpsPps) { //尝试从frame中获取sps pps @@ -187,10 +190,6 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { } } - if(type == H264Frame::NAL_SEI){ - return; - } - if(_lastPacket && _lastPacket->timeStamp != frame->dts()) { RtmpCodec::inputRtmp(_lastPacket, _lastPacket->isVideoKeyFrame()); _lastPacket = nullptr; diff --git a/src/Record/MP4Muxer.cpp b/src/Record/MP4Muxer.cpp index c62c3dbb..af350f67 100644 --- a/src/Record/MP4Muxer.cpp +++ b/src/Record/MP4Muxer.cpp @@ -11,6 +11,7 @@ #ifdef ENABLE_MP4 #include "MP4Muxer.h" #include "Util/File.h" +#include "Extension/H264.h" namespace mediakit{ MP4Muxer::MP4Muxer(const char *file) { @@ -65,7 +66,12 @@ void MP4Muxer::inputFrame(const Frame::Ptr &frame) { int64_t dts_out, pts_out; switch (frame->getCodecId()) { - case CodecH264: + case CodecH264: { + int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); + if(type == H264Frame::NAL_SEI){ + break; + } + } case CodecH265: { //这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理, if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) { diff --git a/src/Record/TsMuxer.cpp b/src/Record/TsMuxer.cpp index 560e2ef6..40bee618 100644 --- a/src/Record/TsMuxer.cpp +++ b/src/Record/TsMuxer.cpp @@ -12,6 +12,7 @@ #if defined(ENABLE_HLS) #include "mpeg-ts-proto.h" #include "mpeg-ts.h" +#include "Extension/H264.h" namespace mediakit { @@ -89,8 +90,13 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) { int64_t dts_out, pts_out; _is_idr_fast_packet = !_have_video; switch (frame->getCodecId()){ - case CodecH265: case CodecH264: { + int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); + if(type == H264Frame::NAL_SEI){ + break; + } + } + case CodecH265: { //这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理, if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) { Frame::Ptr back = _frameCached.back();