From 100822f0797dca54e390c23e991dfd84e8af2aea Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Fri, 21 Jan 2022 18:00:12 +0800 Subject: [PATCH] =?UTF-8?q?HLS:=20=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E5=9B=9E=E9=80=80=E5=AF=BC=E8=87=B4=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90ts=E5=88=87=E7=89=87=E7=9A=84bug:=20#1381,=20#1386?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/HlsMaker.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index afdb7357..f29f55b1 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -73,6 +73,11 @@ void HlsMaker::makeIndexFile(bool eof) { void HlsMaker::inputData(void *data, size_t len, uint32_t timestamp, bool is_idr_fast_packet) { if (data && len) { + if (timestamp < _last_timestamp) { + //时间戳回退了,切片时长重新计时 + WarnL << "stamp reduce: " << _last_timestamp << " -> " << timestamp; + _last_seg_timestamp = _last_timestamp = timestamp; + } if (is_idr_fast_packet) { //尝试切片ts addNewSegment(timestamp); @@ -130,7 +135,6 @@ void HlsMaker::flushLastSegment(bool eof){ seg_dur = 100; } _seg_dur_list.push_back(std::make_tuple(seg_dur, std::move(_last_file_name))); - _last_file_name.clear(); delOldSegment(); //先flush ts切片,否则可能存在ts文件未写入完毕就被访问的情况 onFlushLastSegment(seg_dur);