From patchwork Fri Mar 6 03:58:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongcheng Zhong X-Patchwork-Id: 18069 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 F312D44A484 for ; Fri, 6 Mar 2020 05:58:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D06E368AEB7; Fri, 6 Mar 2020 05:58:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp180.sjtu.edu.cn (smtp180.sjtu.edu.cn [202.120.2.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B4BD68AD75 for ; Fri, 6 Mar 2020 05:58:47 +0200 (EET) Received: from proxy06.sjtu.edu.cn (smtp188.sjtu.edu.cn [202.120.2.188]) by smtp180.sjtu.edu.cn (Postfix) with ESMTPS id AFE4710088A8D for ; Fri, 6 Mar 2020 11:58:44 +0800 (CST) Received: from localhost (localhost.localdomain [127.0.0.1]) by proxy06.sjtu.edu.cn (Postfix) with ESMTP id A9DE0934A4B; Fri, 6 Mar 2020 11:58:44 +0800 (CST) X-Virus-Scanned: amavisd-new at proxy06.sjtu.edu.cn Received: from proxy06.sjtu.edu.cn ([127.0.0.1]) by localhost (proxy06.sjtu.edu.cn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wG81tnKAZ8ag; Fri, 6 Mar 2020 11:58:44 +0800 (CST) Received: from localhost.localdomain (unknown [111.186.45.167]) by proxy06.sjtu.edu.cn (Postfix) with ESMTPSA id 84AC4934A26; Fri, 6 Mar 2020 11:58:42 +0800 (CST) From: Hongcheng Zhong To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Mar 2020 11:58:22 +0800 Message-Id: <1583467102-29502-1-git-send-email-sj.hc_Zhong@sjtu.edu.cn> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH v2] avformat/hlsenc: Fix initial setting for start_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: Hongcheng Zhong MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This patch fixes Bug #8469 If x264 baseline profile is used with other profiles, start_pts will be initialized to audio stream's first pts, while the duration is calculated based on video stream's pts. In this patch the start_pts is initialized with the correct stream's first pts. Signed-off-by: Hongcheng Zhong --- libavformat/hlsenc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index f6dd894..19aa2b1 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -126,6 +126,7 @@ typedef struct VariantStream { int has_video; int has_subtitle; int new_start; + int start_pts_from_audio; double dpp; // duration per packet int64_t start_pts; int64_t end_pts; @@ -2274,6 +2275,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) if (vs->start_pts == AV_NOPTS_VALUE) { vs->start_pts = pkt->pts; + if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) + vs->start_pts_from_audio = 1; + } + if (vs->start_pts_from_audio && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && vs->start_pts > pkt->pts) { + vs->start_pts = pkt->pts; + vs->start_pts_from_audio = 0; } if (vs->has_video) {