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;
}
bool key_frame = frame->keyFrame();
if (_ticker.elapsedTime() > 50 || key_frame) {
//遇到关键帧或者超过50ms则切片
_ticker.resetTime();
auto key_frame = frame->keyFrame();
auto data = _memory_file->getAndClearMemory();
if (!data.empty()) {
//flush切片
saveSegment();
//输出切片数据
onSegmentData(_memory_file->getAndClearMemory(), frame->dts(), _key_frame);
onSegmentData(data, frame->dts(), _key_frame);
_key_frame = false;
}

View File

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