From 602b30f27cc29d985d8eac117af67448cb403db7 Mon Sep 17 00:00:00 2001 From: shenhao <937176211@qq.com> Date: Wed, 23 Oct 2024 12:21:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/HlsMaker.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index fb8380a246..956bf3a201 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -19,8 +19,6 @@ HlsMaker::HlsMaker(float seg_duration, uint32_t seg_number, bool seg_keep) { _seg_number = seg_number; _seg_duration = seg_duration; _seg_keep = seg_keep; - TraceL << "created HlsMaker, seg_duration:" << seg_duration << ", seg_number:" << seg_number - << ", seg_keep:" << seg_keep; } HlsMaker::~HlsMaker() {} @@ -35,7 +33,6 @@ void HlsMaker::makeIndexFile(bool eof) { maxSegmentDuration = dur; } } - TraceL << "maxSegmentDuration:" << maxSegmentDuration; auto sequence = _seg_number ? (_file_index > _seg_number ? _file_index - _seg_number : 0LL) : 0LL; string m3u8; @@ -91,6 +88,9 @@ void HlsMaker::inputData(void *data, size_t len, uint64_t timestamp, bool is_idr } if (is_idr_fast_packet) { // 尝试切片ts + TraceL << "[" << this << "]: " + << "idr fast packet" + << ", timestamp: " << timestamp; addNewSegment(timestamp); } if (!_last_file_name.empty()) { @@ -129,8 +129,12 @@ void HlsMaker::addNewSegment(uint64_t stamp, bool use_fmp4 /*=false*/) { // 存在上个切片,并且未到分片时间 return; } - TraceL << "create new segment, " - << "last_seg_timestamp: " << _last_seg_timestamp << "stamp:" << stamp << ", seg_dur:" << _seg_duration; + + if (stamp - _last_timestamp >= 10 * 1000) { + TraceL << "[" << this << "]: " + << "duration: " << stamp - _last_timestamp << ", last: " << _last_timestamp << ", now: " << stamp; + } + // 关闭并保存上一个切片,如果_seg_number==0,那么是点播。 flushLastSegment(false); // 新增切片