From patchwork Fri May 21 11:46:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Przemys=C5=82aw_Sobala?= X-Patchwork-Id: 27891 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp441793iof; Fri, 21 May 2021 04:47:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv+XSD+TQCrJTIN9viZQ+D0UzzfCuiZQCBJ2bi8VqYtGnmVjfESxXv5n1kL1bHghv+KoaR X-Received: by 2002:a50:ed13:: with SMTP id j19mr10786198eds.190.1621597621385; Fri, 21 May 2021 04:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621597621; cv=none; d=google.com; s=arc-20160816; b=RxZ4IFTTLryGXzkOgU71M83rg70hKuljP+JrxXC/R4b6klk2ES/3uwAYIWpKBRVxDt BiNJOcua3i+P1u3cLHLutHZySYGTbICoguSaX633frLTAj2zWQsXpiG1RcEwZZCDrXhQ kpvBhdEBTJemfYp6eruMT4KlTh0E8rNbODNU1C+x62ft3SiCkI1dd/KVZ08nFaxVKzmT hjVpPWWy6DZy4+gK5d2k6dcylp/Gq9O03QQ6eohlgP7hMsi9WUcB5LOq60ok9HfAPAH6 r1MbIhUTaYRNrCMxtrmroy/MoFigBe/0jylpcCYweHOQXZRa9ifmyNf1SN8krjO3FFOb WRGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=fpkIx5D5Y0LEHTRammeJzTJz1phGkBX0XGusCAe7mnc=; b=kuLzUNVP1l6Fvr5NKzgY97bpQOW4uRaq4N8aj0s4BLqEtF09Q2M6UiKhaeRjLQqJFE 2YsSL/20S6qgXq2X2HuL7n4VmYDGNKStzRXMOSC7p0qzpXuezFqwTxk4YMUapcK0y8CY mzHZOMm2BeFKpZEDi9kp6f+7iFXj1QyjQcHrLIkRkELC7I0PM0p3Q5FyFau+HdGvTSTg 0VpX5jBfRlUxkL5otN8WXB8F5Y7Iz7ql5GBp+EYCzENqRVenGtOgLqivbSAe/jZL0d/a 7NX8vPytAi6xiweQJq6xbs9PaX4OOoI6UeU3gZZ7KdJqrpVrIOP6AA1+/Xkli7XDEuuD 4RrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=qKB17o8u; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g19si3249362edu.41.2021.05.21.04.47.00; Fri, 21 May 2021 04:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=qKB17o8u; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 76898688095; Fri, 21 May 2021 14:46:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C58A8680C21 for ; Fri, 21 May 2021 14:46:50 +0300 (EEST) Received: by mail-ej1-f54.google.com with SMTP id gb17so11989187ejc.8 for ; Fri, 21 May 2021 04:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VOu5zde3FUtABD4DG6blKhoYp4dwiwmjbED6UCmociw=; b=qKB17o8umYQsRSS9aviPbbG8y84Py7mjI8BoehjkfKp73eatnCHMKpJkVxwxlGp9Ut ynUYSOR7EMBYyPhjY0+2AoVqXCxyOKQBIlYV87eYO0KU8+Ku1CN75B4wPzWzMSr8CKz7 FtCi9S6k5oh69+EsRoE5CbdQSVmbfgGOcBNValwwpiXr+yQPa5hL4iQy/eleiBKtl59H O5Py9Zgy+Ge/1+ZyG9FnRpUek2iee7Cln+XwwZMNtgRS8As8xVsHFFs8Y9LMQBKBGSHH K/vEzT39imUBytRkqGWeqwHjPsVoFcYAZ5dNAHJ0o71Ke88OEwfUoClrM8Fm7jOhoLIR ojVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VOu5zde3FUtABD4DG6blKhoYp4dwiwmjbED6UCmociw=; b=Ast294rk8tc6XW4ba5/2xddIPJ2kUAKRvQGuNLPU9JQCKdriJ+umCwLNkUmdtXn2GE ZO1bls9YfPqIjce+VAvi2ZxXxjQQqJMM5e26G8GUP7eA3LW1CmKrtgKGG1t151zReTId wA3wHB/SQEzwkTM/hDFyZPadMngDTijIxs66x9+4cZFiP9c+bqMFFFpn29/7I8xHCdT7 c8XnbZ166wrKCR3qb3afxuqoZS1C1lATgqUKi8vpfV1DckjbAiDxbGFd/lT/gK7RRa6v YzZgGr+0VGQsECK/5DqXRlAmY2BMZGw3omHAxY3+cvv8SxD+KeobMfV0gQ3sshvnoKxv qLgg== X-Gm-Message-State: AOAM533xBMZNQVqGRLHrq6S+XUWw+WMrfxBWimGIv1WMbMrYqsugHVsC LK+ezRoltkGNL1ed6elvKxS48kgwD0RTnQ== X-Received: by 2002:a17:906:fc0d:: with SMTP id ov13mr9712923ejb.504.1621597610243; Fri, 21 May 2021 04:46:50 -0700 (PDT) Received: from pszemus-dell.home (83.8.213.74.ipv4.supernova.orange.pl. [83.8.213.74]) by smtp.googlemail.com with ESMTPSA id bv17sm3347143ejb.37.2021.05.21.04.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 04:46:49 -0700 (PDT) From: =?utf-8?q?Przemys=C5=82aw_Sobala?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 13:46:42 +0200 Message-Id: <20210521114642.66802-1-przemyslaw.sobala@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: =?utf-8?q?Przemys=C5=82aw_Sobala?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IIRfHg0kEpeZ With audio/video HLS playlists, audio chunklists are treated as alternative renditions for video chunklists. This is wrong for audio-only HLS playlists. fixes: 9252 Please correct indentation of introduced if statement's body, before applying. --- libavformat/dashenc.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 07f191e2a2..c5da02840b 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1256,10 +1256,6 @@ static int write_manifest(AVFormatContext *s, int final) if (c->hls_playlist) { char filename_hls[1024]; - const char *audio_group = "A1"; - char audio_codec_str[128] = "\0"; - int is_default = 1; - int max_audio_bitrate = 0; // Publish master playlist only the configured rate if (c->master_playlist_created && (!c->master_publish_rate || @@ -1282,6 +1278,13 @@ static int write_manifest(AVFormatContext *s, int final) ff_hls_write_playlist_version(c->m3u8_out, 7); + if (c->has_video) { + // treat audio streams as alternative renditions for video streams + const char *audio_group = "A1"; + char audio_codec_str[128] = "\0"; + int is_default = 1; + int max_audio_bitrate = 0; + for (i = 0; i < s->nb_streams; i++) { char playlist_file[64]; AVStream *st = s->streams[i]; @@ -1336,6 +1339,34 @@ static int write_manifest(AVFormatContext *s, int final) playlist_file, agroup, codec_str_ptr, NULL, NULL); } + + } else { + // treat audio streams as separate renditions + + for (i = 0; i < s->nb_streams; i++) { + char playlist_file[64]; + char codec_str[128]; + AVStream *st = s->streams[i]; + OutputStream *os = &c->streams[i]; + int stream_bitrate = os->muxer_overhead; + if (os->bit_rate > 0) + stream_bitrate += os->bit_rate; + else if (final) + stream_bitrate += os->pos * 8 * AV_TIME_BASE / c->total_duration; + else if (os->first_segment_bit_rate > 0) + stream_bitrate += os->first_segment_bit_rate; + if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) + continue; + if (os->segment_type != SEGMENT_TYPE_MP4) + continue; + av_strlcpy(codec_str, os->codec_str, sizeof(codec_str)); + get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); + ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate, + playlist_file, NULL, + codec_str, NULL, NULL); + } + } + dashenc_io_close(s, &c->m3u8_out, temp_filename); if (use_rename) if ((ret = ff_rename(temp_filename, filename_hls, s)) < 0)