From patchwork Wed Apr 29 12:39:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 19368 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 44ADF448F1E for ; Wed, 29 Apr 2020 15:39:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13D7368BFB5; Wed, 29 Apr 2020 15:39:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 733B668B74B for ; Wed, 29 Apr 2020 15:39:49 +0300 (EEST) X-QQ-mid: bizesmtp5t1588163971tn7c8iv0z Received: from localhost (unknown [221.216.234.164]) by esmtp6.qq.com (ESMTP) with id ; Wed, 29 Apr 2020 20:39:30 +0800 (CST) X-QQ-SSF: 01100000002000Y0ZWF0000A0000000 X-QQ-FEAT: q4K17BezYbpquOgOnXHFvG2eHZy+59cQ/D/HAhT38aj/JoSfJSU2APsDkbHq8 AAlqKziwGVU7ia/ny+dNXC4M78+ZU+MPEIb7T8s2nsErYQTL5vSx3gRZcb5gn7z5Ydy85Wy s83iX35+82W7LBpPN4T1MxrOh8oMZeO7QPRgh/IzHTwM3Yc4jMsp7MU53J/9+NFz17p/l0u +DwM2Ffu6CIkfJXht+B6U87WPgaxmU/eXKneFS+wAyQPmSylwPrpKo20o5jn6QliuholbJw 158OyJAtFo5PEYQdvJREFA5hNWRUda+a0tCfOaabbI7a7KMjng65sThndgpAgNUnaB3FfP8 8cv4nG0dknk3MaFhIA= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 Apr 2020 20:39:22 +0800 Message-Id: <20200429123922.66870-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2] avformat/hlsenc: compute segment duration use current pts minus last segment end pts 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: Zhao Jun , Steven Liu , Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" segment duration is using vs duration which compute by frame per second, that can not fix problem of VFR video stream, so compute the duration when split the segment, set the segment target duration use current packet pts minus the prev segment end pts.. Reported-by: Zhao Jun Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index d75684741f..4a83db04e9 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2460,7 +2460,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) } if (vs->start_pos || hls->segment_type != SEGMENT_TYPE_FMP4) { - ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, vs->size); + double cur_duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den; + ret = hls_append_segment(s, hls, vs, cur_duration, vs->start_pos, vs->size); vs->end_pts = pkt->pts; vs->duration = 0; if (ret < 0) {