From patchwork Mon Aug 17 09:53:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 21690 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 5F2F844ACD3 for ; Mon, 17 Aug 2020 12:53:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A2DE68B7AB; Mon, 17 Aug 2020 12:53:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 841B268A98A for ; Mon, 17 Aug 2020 12:53:46 +0300 (EEST) X-QQ-mid: bizesmtp8t1597658019t7ajjk2e6 Received: from localhost (unknown [103.107.216.231]) by esmtp6.qq.com (ESMTP) with id ; Mon, 17 Aug 2020 17:53:38 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000000A0000000 X-QQ-FEAT: MuS5HDhwC6+dLlFcg2yTZTfBzEHvjQT0BuIxsiG9EKoC9pBwJtzjj8AA02uYR ZG8EQ698pEyMhq+M88/n5+0Pa0as4HnNpcyaXSLR2N3ERkEGFS6NIDADt4/BaUa5Q0wfs5q lquQpA/ogfeQw0YlrTUcOdQhE2SInOG5rH9WKm4XpuWA2/+rilY3wnC5bjYanGv8vSZYJ0y MTu9RiwFMCT6oV4u45DiZR83ObMkYEfAJOtkM52aL7ZVTpHuDSZwm/YBNleBwsSWuhBsqSh BbCKwrBbcMxa+mV1PgS4Qf+DzIG+Hr9mT9r09xFiUXNG4Wsy4TSt/6o84ClJZC8gATPc6/K FHSSejC X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Aug 2020 17:53:37 +0800 Message-Id: <20200817095337.89430-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200817092531.php2bxg4mt45ejlr@phare.normalesup.org> References: <20200817092531.php2bxg4mt45ejlr@phare.normalesup.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: check duration value correct before split segment 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" fix ticket: 8847 check the timestamps of current packets minus last segment end_pts if the duration is negative, plus the places where the muxer should split. Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index cb31d6aed7..3564c68732 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2398,9 +2398,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) vs->duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den; } } - } + can_split = pkt->pts - vs->end_pts < 0 ? 0 : 1; if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base, end_pts, AV_TIME_BASE_Q) >= 0) { int64_t new_start_pos;