FMP4: http-fmp4直播提升流畅度

This commit is contained in:
ziyue 2021-12-16 12:09:49 +08:00
parent f4b6a6bd40
commit 4291c31493
2 changed files with 4 additions and 6 deletions

View File

@ -319,14 +319,13 @@ bool MP4MuxerMemory::inputFrame(const Frame::Ptr &frame){
return false; return false;
} }
bool key_frame = frame->keyFrame(); auto key_frame = frame->keyFrame();
if (_ticker.elapsedTime() > 50 || key_frame) { auto data = _memory_file->getAndClearMemory();
//遇到关键帧或者超过50ms则切片 if (!data.empty()) {
_ticker.resetTime();
//flush切片 //flush切片
saveSegment(); saveSegment();
//输出切片数据 //输出切片数据
onSegmentData(_memory_file->getAndClearMemory(), frame->dts(), _key_frame); onSegmentData(data, frame->dts(), _key_frame);
_key_frame = false; _key_frame = false;
} }

View File

@ -141,7 +141,6 @@ protected:
private: private:
bool _key_frame = false; bool _key_frame = false;
Ticker _ticker;
string _init_segment; string _init_segment;
MP4FileMemory::Ptr _memory_file; MP4FileMemory::Ptr _memory_file;
}; };