From patchwork Tue Aug 18 02:44:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 21696 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 C855C449815 for ; Tue, 18 Aug 2020 05:44:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A9B2468B923; Tue, 18 Aug 2020 05:44:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDD5A68B86F for ; Tue, 18 Aug 2020 05:44:29 +0300 (EEST) X-QQ-mid: bizesmtp9t1597718662tq10diyks Received: from localhost (unknown [103.107.216.230]) by esmtp6.qq.com (ESMTP) with id ; Tue, 18 Aug 2020 10:44:21 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: b0oIbfUHMAjOdjuaNhtMuaZJ2+SJNOpjtB4YxLdCL18vHbeIhS6su+IUVpzDG 3x2S99Zsy+kKxin+rRiBkakVUN/r5FE9OOk/sPdeQhXdsZNCTDSbqmXd8cpUID3i5hE/XJh begr/thTD///EsP9yIH/KKpxW/SXuuOuPjgg1TnmMtTn1amibLNSMVMBMkX3WCWMYEmO0nj Xqc5kBtWu7W5zobp7NOBeOJHz4wuXrJmsEZvbcnzP1C38jNpVG/e1W9yX2WP/MqmY9s2XRg 3bfg5/yAw+c2XusuzLHlXSbBwddesDgwwP3YBYYYG+k901 X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Aug 2020 10:44:11 +0800 Message-Id: <20200818024411.31718-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:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: process hls_time value too small sence 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 , Zhili Zhao Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The target duration will be a negative value when there are some b frames after prevous frame, the pts after current packet is large than the pts of current packet, so the target duration will compute as 0.040000 - 0.080000, then the value of the target duration will be -0.040000. so hls muxer should check the pts after current packet minus the pts of current packet, hls muxer can split the stream as a segment if the target duration is neither negative nor zero, hls muxer cannot split the stream as a segment if the target duration is either negative or zero then get the next packet until the target duration is not negative or zero. Signed-off-by: Steven Liu Suggested-by: Zhili Zhao --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index cb31d6aed7..4471858222 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 = can_split && (pkt->pts - vs->end_pts > 0); 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;