mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
HTTP-FMP4: 修复http-fmp4直播秒开问题
This commit is contained in:
parent
4291c31493
commit
120879df0f
@ -64,9 +64,7 @@ public:
|
||||
*/
|
||||
void setInitSegment(string str) {
|
||||
_init_segment = std::move(str);
|
||||
if (_ring) {
|
||||
regist();
|
||||
}
|
||||
createRing();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSegmentData(const string &string, uint32_t stamp, bool key_frame) override {
|
||||
void onSegmentData(string string, uint32_t stamp, bool key_frame) override {
|
||||
if (string.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,9 +9,11 @@
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_MP4
|
||||
|
||||
#include "MP4Muxer.h"
|
||||
#include "Util/File.h"
|
||||
#include "Extension/H264.h"
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
MP4Muxer::MP4Muxer() {}
|
||||
@ -84,7 +86,6 @@ bool MP4MuxerInterface::inputFrame(const Frame::Ptr &frame) {
|
||||
//mp4文件时间戳需要从0开始
|
||||
auto &track_info = it->second;
|
||||
int64_t dts_out, pts_out;
|
||||
|
||||
switch (frame->getCodecId()) {
|
||||
case CodecH264:
|
||||
case CodecH265: {
|
||||
@ -319,22 +320,24 @@ bool MP4MuxerMemory::inputFrame(const Frame::Ptr &frame){
|
||||
return false;
|
||||
}
|
||||
|
||||
auto key_frame = frame->keyFrame();
|
||||
auto data = _memory_file->getAndClearMemory();
|
||||
if (!data.empty()) {
|
||||
bool key_frame = frame->keyFrame();
|
||||
|
||||
//flush切片
|
||||
saveSegment();
|
||||
|
||||
auto data = _memory_file->getAndClearMemory();
|
||||
if (!data.empty()) {
|
||||
//输出切片数据
|
||||
onSegmentData(data, frame->dts(), _key_frame);
|
||||
onSegmentData(std::move(data), frame->dts(), _key_frame);
|
||||
_key_frame = false;
|
||||
}
|
||||
|
||||
if (key_frame) {
|
||||
_key_frame = true;
|
||||
}
|
||||
|
||||
return MP4MuxerInterface::inputFrame(frame);
|
||||
}
|
||||
|
||||
|
||||
}//namespace mediakit
|
||||
#endif//#ifdef ENABLE_MP4
|
||||
|
@ -134,7 +134,7 @@ protected:
|
||||
* @param stamp 切片末尾时间戳
|
||||
* @param key_frame 是否有关键帧
|
||||
*/
|
||||
virtual void onSegmentData(const string &string, uint32_t stamp, bool key_frame) = 0;
|
||||
virtual void onSegmentData(string string, uint32_t stamp, bool key_frame) = 0;
|
||||
|
||||
protected:
|
||||
MP4FileIO::Writer createWriter() override;
|
||||
|
Loading…
Reference in New Issue
Block a user