From patchwork Mon Aug 17 00:49:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 21685 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5EFA444A4BD for ; Mon, 17 Aug 2020 03:51:05 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EAD468B74B; Mon, 17 Aug 2020 03:51:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from qq.com (unknown [183.3.226.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CC1F768A353 for ; Mon, 17 Aug 2020 03:50:58 +0300 (EEST) X-QQ-mid: bizesmtp8t1597625386ta206focc Received: from localhost (unknown [103.107.216.230]) by esmtp6.qq.com (ESMTP) with id ; Mon, 17 Aug 2020 08:49:45 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: ME5hZAOEvdg76mX/R35Hsp7gnjBlRU8dYwXuZ8zW52WF+nwY9ERRmIoglzZjQ 3wEoWmB6EGf2hy8+ZTYWHJ7M9HvUOCIalN3ReScYBRd7na47fX6OgN9M2wsW796mgfR2ZUF AfWSnFrXoZuw3pv4uUGglGS7H52dwafpzCqB0pM4u0w602KoNIxu9wHKn76sphMrbirxRkb wuXu5c6RM/l7cxo8VD3w6hWXPLEW9cp2txCkLDKvIUwlnSYRtA5r18c1l9D6jBSJjG7nH3s xy7p6dM3IlsZ6ybC1TDsT1E+RqAKbvEt5F7fDNCMV2cnRz X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Aug 2020 08:49:44 +0800 Message-Id: <20200817004944.62003-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgweb:qybgweb11 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: check the segment duration valid X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" output a warning message if the target duration of the segment. and modify the target duration to one packet duration, because there maybe have bframe and then split not by keyframe, and the segment is very very small. Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index cb31d6aed7..76d59f5f79 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2512,6 +2512,11 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) if (vs->start_pos || hls->segment_type != SEGMENT_TYPE_FMP4) { double cur_duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den; + if (cur_duration < 0) { + av_log(s, AV_LOG_WARNING, "duration < 0, maybe you splited a too short segment, " + "the duration will set to 1 packet duration.\n"); + cur_duration = vs->duration; + } ret = hls_append_segment(s, hls, vs, cur_duration, vs->start_pos, vs->size); vs->end_pts = pkt->pts; vs->duration = 0;