H264Track不过滤SEI: #411

This commit is contained in:
xiongziliang 2020-07-16 16:26:13 +08:00
parent c612f291db
commit c31b0cc26b
4 changed files with 17 additions and 11 deletions

View File

@ -228,11 +228,6 @@ private:
} }
break; break;
case H264Frame::NAL_SEI:{
//忽略SEI
break;
}
default: default:
VideoTrack::inputFrame(frame); VideoTrack::inputFrame(frame);
break; break;

View File

@ -166,6 +166,9 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
auto pcData = frame->data() + frame->prefixSize(); auto pcData = frame->data() + frame->prefixSize();
auto iLen = frame->size() - frame->prefixSize(); auto iLen = frame->size() - frame->prefixSize();
auto type = H264_TYPE(((uint8_t*)pcData)[0]); auto type = H264_TYPE(((uint8_t*)pcData)[0]);
if(type == H264Frame::NAL_SEI){
return;
}
if (!_gotSpsPps) { if (!_gotSpsPps) {
//尝试从frame中获取sps pps //尝试从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()) { if(_lastPacket && _lastPacket->timeStamp != frame->dts()) {
RtmpCodec::inputRtmp(_lastPacket, _lastPacket->isVideoKeyFrame()); RtmpCodec::inputRtmp(_lastPacket, _lastPacket->isVideoKeyFrame());
_lastPacket = nullptr; _lastPacket = nullptr;

View File

@ -11,6 +11,7 @@
#ifdef ENABLE_MP4 #ifdef ENABLE_MP4
#include "MP4Muxer.h" #include "MP4Muxer.h"
#include "Util/File.h" #include "Util/File.h"
#include "Extension/H264.h"
namespace mediakit{ namespace mediakit{
MP4Muxer::MP4Muxer(const char *file) { MP4Muxer::MP4Muxer(const char *file) {
@ -65,7 +66,12 @@ void MP4Muxer::inputFrame(const Frame::Ptr &frame) {
int64_t dts_out, pts_out; int64_t dts_out, pts_out;
switch (frame->getCodecId()) { 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: { case CodecH265: {
//这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理 //这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理
if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) { if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) {

View File

@ -12,6 +12,7 @@
#if defined(ENABLE_HLS) #if defined(ENABLE_HLS)
#include "mpeg-ts-proto.h" #include "mpeg-ts-proto.h"
#include "mpeg-ts.h" #include "mpeg-ts.h"
#include "Extension/H264.h"
namespace mediakit { namespace mediakit {
@ -89,8 +90,13 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
int64_t dts_out, pts_out; int64_t dts_out, pts_out;
_is_idr_fast_packet = !_have_video; _is_idr_fast_packet = !_have_video;
switch (frame->getCodecId()){ switch (frame->getCodecId()){
case CodecH265:
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这些时间戳相同的帧打包到一起当做一个帧处理 //这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理
if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) { if (!_frameCached.empty() && _frameCached.back()->dts() != frame->dts()) {
Frame::Ptr back = _frameCached.back(); Frame::Ptr back = _frameCached.back();