mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
新增兜底机制确保事件录制视频能正常结束
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
This commit is contained in:
parent
92d9e59cc0
commit
c9490ad764
@ -457,13 +457,16 @@ std::string MultiMediaSourceMuxer::startRecord(const std::string &file_path, uin
|
|||||||
auto reader = _ring->attach(MultiMediaSourceMuxer::getOwnerPoller(MediaSource::NullMediaSource()), false);
|
auto reader = _ring->attach(MultiMediaSourceMuxer::getOwnerPoller(MediaSource::NullMediaSource()), false);
|
||||||
uint64_t now_dts = 0;
|
uint64_t now_dts = 0;
|
||||||
int selected_index = -1;
|
int selected_index = -1;
|
||||||
reader->setReadCB([muxer, now_dts, selected_index, forward_time_ms, reader, path](const Frame::Ptr &frame) mutable {
|
Ticker ticker;
|
||||||
|
bool is_live_stream = _dur_sec < 0.01;
|
||||||
|
reader->setReadCB([muxer, now_dts, selected_index, forward_time_ms, reader, path, ticker, is_live_stream](const Frame::Ptr &frame) mutable {
|
||||||
// 循环引用自身
|
// 循环引用自身
|
||||||
if (!now_dts) {
|
if (!now_dts) {
|
||||||
now_dts = frame->dts();
|
now_dts = frame->dts();
|
||||||
selected_index = frame->getIndex();
|
selected_index = frame->getIndex();
|
||||||
}
|
}
|
||||||
if (frame->getIndex() == selected_index && now_dts + forward_time_ms < frame->dts()) {
|
// 新增兜底机制,如果直播录制任务时长超过预期时间3秒,不管数据时间戳是否增长是否达到预期,都强制停止录制
|
||||||
|
if ((frame->getIndex() == selected_index && now_dts + forward_time_ms < frame->dts()) || (is_live_stream && ticker.createdTime() > forward_time_ms + 3000)) {
|
||||||
InfoL << "stop record: " << path << ", end dts: " << frame->dts();
|
InfoL << "stop record: " << path << ", end dts: " << frame->dts();
|
||||||
WorkThreadPool::Instance().getPoller()->async([muxer]() { muxer->closeMP4(); });
|
WorkThreadPool::Instance().getPoller()->async([muxer]() { muxer->closeMP4(); });
|
||||||
reader = nullptr;
|
reader = nullptr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user