mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-06 20:23:43 +08:00
修复首帧不是I帧 导致花屏的问题
This commit is contained in:
parent
0980bde12d
commit
35c324b6b4
|
@ -79,6 +79,14 @@ void MP4Muxer::onTrackFrame(const Frame::Ptr &frame) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(frame->getTrackType() == TrackVideo){
|
||||||
|
if(!_started && !frame->keyFrame()){
|
||||||
|
//第一帧必须是I帧,防止花屏
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_started = true;
|
||||||
|
}
|
||||||
|
|
||||||
int with_nalu_size ;
|
int with_nalu_size ;
|
||||||
switch (frame->getCodecId()){
|
switch (frame->getCodecId()){
|
||||||
case CodecH264:
|
case CodecH264:
|
||||||
|
|
|
@ -80,6 +80,7 @@ private:
|
||||||
uint32_t start_pts = 0;
|
uint32_t start_pts = 0;
|
||||||
};
|
};
|
||||||
map<CodecId,track_info> _codec_to_trackid;
|
map<CodecId,track_info> _codec_to_trackid;
|
||||||
|
bool _started = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,10 +89,8 @@ void Mp4Maker::createFile() {
|
||||||
try {
|
try {
|
||||||
_muxer = std::make_shared<MP4MuxerFile>(strFileTmp.data());
|
_muxer = std::make_shared<MP4MuxerFile>(strFileTmp.data());
|
||||||
for(auto &track :_tracks){
|
for(auto &track :_tracks){
|
||||||
if(track){
|
//添加track
|
||||||
//添加track
|
_muxer->addTrack(track);
|
||||||
_muxer->addTrack(track);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_strFileTmp = strFileTmp;
|
_strFileTmp = strFileTmp;
|
||||||
_strFile = strFile;
|
_strFile = strFile;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user