From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 15CDA4789C for ; Fri, 27 Oct 2023 01:44:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 127B968CBAA; Fri, 27 Oct 2023 04:44:13 +0300 (EEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EED6568CB85 for ; Fri, 27 Oct 2023 04:44:05 +0300 (EEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6bee11456baso1497325b3a.1 for ; Thu, 26 Oct 2023 18:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698371043; x=1698975843; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7JC497foabMutnp0VSgAcsnT58Ap5tHjG/HNhX4u6ec=; b=TRmbFnwR2tCkbfWOQqnVzziyPBrBvhD7k4Si9bfdmDOEfwTNRXuIpWaK3Etc+djyzU radMepEds9xDmVC1tpDVh8SBvUo6txHLGEMeJIBQPoAJvIj61X8B7QRjCckA/FVFYZZ6 Gn7lK+lTPNjP3ktRbW6MRjtZWNSoKVd8VXWF04QnUIImPRHOU3mnVTOnfYc0qUp1ZR0g aiQcfm6u2qI6o3VAF9CJ5fg/Q3Z1hiNFPJLqCIL+CGwIDQCU5bUuxxL9y0a3WhG7ipEu 22uqsYwzaj/I4++bbZM64kno25iajbF87ZkwDlCOTbPF3XU3CPtzGggnvcpfM/K0gPO/ lbqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698371043; x=1698975843; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7JC497foabMutnp0VSgAcsnT58Ap5tHjG/HNhX4u6ec=; b=DpGYnJIUXR68+omoof7AhPg/Q2jLhalqVt6jG3wdMmeu1OGtOp0dVMSOlahS3j7027 zp2fvZkhXjC7tQ07kYwQXjhQqmRnBSZhVh5Q7Dk8SpX2FBrq9kaglzGnjgdBNVXwrv5N em8cIXsOL6sSj9O9dz0Z61BfzP4hV6i6Yg2kkSEZf7U+CzEEOQc0rBqUkrmAl9nEEDAe 7Czt26FU2d/zlVUw3gPshx36fRLuOC1uZH/Wmd8DIQLhPMFvQMkVojB8Irbc5zrJdkJ/ qhp39coW6N6Pm0JCDo1OM99ScPgvVeXn9drq9XbS3JJLn4yjaNQyvhuylkgwds81iz7Z sjzQ== X-Gm-Message-State: AOJu0YyNvm2nMiciiVVDXHScKJYhByrKhKyHen43DEiQ5SJNnJ7njDZV 7GHduVi3Tp9/ij1qnhVvxl0nFv9e9mBbug== X-Google-Smtp-Source: AGHT+IGZTGaEN0YeqC7mwtVojRp4AEvLbXG1jLE+ya59LdHqMTjFaN4xbupmaGNy3Dtz5mVFO5hZXw== X-Received: by 2002:a05:6a21:7747:b0:16b:c8f8:a53c with SMTP id bc7-20020a056a21774700b0016bc8f8a53cmr1290009pzc.47.1698371042819; Thu, 26 Oct 2023 18:44:02 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:a98f:6200:f8bd:26eb:4d2d:1b2b]) by smtp.gmail.com with ESMTPSA id b13-20020a170902650d00b001c736b0037fsm338158plk.231.2023.10.26.18.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 18:44:02 -0700 (PDT) From: Dave Johansen To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Oct 2023 19:43:59 -0600 Message-Id: <20231027014359.20208-1-davejohansen@gmail.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: Add CHANNELS to EXT-X-MEDIA for Audio 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: Dave Johansen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavformat/dashenc.c | 3 ++- libavformat/hlsenc.c | 8 +++++++- libavformat/hlsplaylist.c | 5 ++++- libavformat/hlsplaylist.h | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 96f4a5fbdf..15f700acbc 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1284,7 +1284,8 @@ static int write_manifest(AVFormatContext *s, int final) continue; get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); ff_hls_write_audio_rendition(c->m3u8_out, audio_group, - playlist_file, NULL, i, is_default); + playlist_file, NULL, i, is_default, + s->streams[i]->codecpar->ch_layout.nb_channels); max_audio_bitrate = FFMAX(st->codecpar->bit_rate + os->muxer_overhead, max_audio_bitrate); if (!av_strnstr(audio_codec_str, os->codec_str, sizeof(audio_codec_str))) { diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 4ef84c05c1..7dfb8d0a9f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1386,6 +1386,7 @@ static int create_master_playlist(AVFormatContext *s, int is_file_proto = proto && !strcmp(proto, "file"); int use_temp_file = is_file_proto && ((hls->flags & HLS_TEMP_FILE) || hls->master_publish_rate); char temp_filename[MAX_URL_SIZE]; + int nb_channels; input_vs->m3u8_created = 1; if (!hls->master_m3u8_created) { @@ -1434,8 +1435,13 @@ static int create_master_playlist(AVFormatContext *s, av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n"); goto fail; } + nb_channels = 0; + for (j = 0; j < vs->nb_streams; j++) + if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) + if (vs->streams[j]->codecpar->ch_layout.nb_channels > nb_channels) + nb_channels = vs->streams[j]->codecpar->ch_layout.nb_channels; - ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1); + ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name, vs->language, i, hls->has_default_key ? vs->is_default : 1, nb_channels); } /* For variant streams with video add #EXT-X-STREAM-INF tag with attributes*/ diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c index 2bf05f3c7c..4f35d0388f 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -39,7 +39,7 @@ void ff_hls_write_playlist_version(AVIOContext *out, int version) void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, const char *filename, const char *language, - int name_id, int is_default) + int name_id, int is_default, int nb_channels) { if (!out || !agroup || !filename) return; @@ -49,6 +49,9 @@ void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, if (language) { avio_printf(out, "LANGUAGE=\"%s\",", language); } + if (nb_channels) { + avio_printf(out, "CHANNELS=\"%d\",", nb_channels); + } avio_printf(out, "URI=\"%s\"\n", filename); } diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h index 1928fe787d..c2744c227c 100644 --- a/libavformat/hlsplaylist.h +++ b/libavformat/hlsplaylist.h @@ -38,7 +38,7 @@ typedef enum { void ff_hls_write_playlist_version(AVIOContext *out, int version); void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, const char *filename, const char *language, - int name_id, int is_default); + int name_id, int is_default, int nb_channels); void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, int name_id, int is_default); -- 2.39.2 (Apple Git-143) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".