From 7f07eec9042ae62a1e1c6719c0ad4f8fffc2775f Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 4 Nov 2024 11:55:21 -0800 Subject: [PATCH] fix(HLS): Fix audio grouping by codec (#185) Instead of something like this (Packager's default): ``` #EXT-X-MEDIA:TYPE=AUDIO,URI="aac.m3u8",GROUP-ID="audio",LANGUAGE="en",NAME="aac",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=AUDIO,URI="ac3.m3u8",GROUP-ID="audio",LANGUAGE="en",NAME="ac3",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=973060,AVERAGE-BANDWIDTH=973259,CODECS="avc1.4d401e,mp4a.40.2,ac3",RESOLUTION=846x360,FRAME-RATE=24.000,AUDIO="audio",CLOSED-CAPTIONS=NONE video.m3u8 ``` We should split the audio groups by codec: ``` #EXT-X-MEDIA:TYPE=AUDIO,URI="aac.m3u8",GROUP-ID="aac",LANGUAGE="en",NAME="aac",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=AUDIO,URI="ac3.m3u8",GROUP-ID="ac3",LANGUAGE="en",NAME="ac3",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=973060,AVERAGE-BANDWIDTH=973259,CODECS="avc1.4d401e,mp4a.40.2",RESOLUTION=846x360,FRAME-RATE=24.000,AUDIO="aac",CLOSED-CAPTIONS=NONE video.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=973060,AVERAGE-BANDWIDTH=973259,CODECS="avc1.4d401e,ac3",RESOLUTION=846x360,FRAME-RATE=24.000,AUDIO="ac3",CLOSED-CAPTIONS=NONE video.m3u8 ``` This can be done in the stream descriptor config for Shaka Packager. Streamer will now always split up audio groups by codec. --- streamer/packager_node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/streamer/packager_node.py b/streamer/packager_node.py index 10df985..0ad2da1 100644 --- a/streamer/packager_node.py +++ b/streamer/packager_node.py @@ -21,6 +21,7 @@ from . import node_base from . import pipeline_configuration +from streamer.input_configuration import MediaType from streamer.output_stream import OutputStream from streamer.pipeline_configuration import EncryptionMode, PipelineConfig from streamer.util import is_url @@ -126,7 +127,6 @@ def start(self) -> None: stdout=stdout) def _setup_stream(self, stream: OutputStream) -> str: - dict = { 'in': stream.ipc_pipe.read_end(), 'stream': stream.type.value, @@ -135,6 +135,9 @@ def _setup_stream(self, stream: OutputStream) -> str: if stream.input.skip_encryption: dict['skip_encryption'] = str(stream.input.skip_encryption) + if stream.type == MediaType.AUDIO: + dict['hls_group_id'] = str(stream.codec.value) + if stream.input.drm_label: dict['drm_label'] = stream.input.drm_label