From 5ad41ab34de193e1ab7aabad09e2a6e1f98ad4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Mon, 11 Nov 2024 11:37:36 +0100 Subject: [PATCH 1/2] feat: Add generate_iframe_playlist option --- streamer/output_stream.py | 8 ++++++++ streamer/packager_node.py | 5 ++++- streamer/pipeline_configuration.py | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/streamer/output_stream.py b/streamer/output_stream.py index ac9de99..b76811c 100644 --- a/streamer/output_stream.py +++ b/streamer/output_stream.py @@ -88,6 +88,14 @@ def get_single_seg_file(self) -> Pipe: path_templ = SINGLE_SEGMENT[self.type].format(**self.features) return Pipe.create_file_pipe(path_templ, mode='w') + def get_identification(self) -> str: + SINGLE_SEGMENT = { + MediaType.AUDIO: 'audio_{language}_{channels}c_{bitrate}_{codec}_{format}', + MediaType.VIDEO: 'video_{resolution_name}_{bitrate}_{codec}_{format}', + MediaType.TEXT: 'text_{language}_{format}', + } + return SINGLE_SEGMENT[self.type].format(**self.features) + class AudioOutputStream(OutputStream): diff --git a/streamer/packager_node.py b/streamer/packager_node.py index e80019b..3625f38 100644 --- a/streamer/packager_node.py +++ b/streamer/packager_node.py @@ -21,7 +21,7 @@ from . import node_base from . import pipeline_configuration -from streamer.bitrate_configuration import AudioCodec +from streamer.bitrate_configuration import AudioCodec, VideoCodec from streamer.input_configuration import MediaType from streamer.output_stream import OutputStream from streamer.pipeline_configuration import EncryptionMode, PipelineConfig @@ -141,6 +141,9 @@ def _setup_stream(self, stream: OutputStream) -> str: if stream.type == MediaType.AUDIO: dict['hls_group_id'] = str(cast(AudioCodec, stream.codec).value) + if stream.type == MediaType.VIDEO and self._pipeline_config.generate_iframe_playlist: + dict['iframe_playlist_name'] = stream.get_identification() + '.m3u8' + if stream.input.drm_label: dict['drm_label'] = stream.input.drm_label diff --git a/streamer/pipeline_configuration.py b/streamer/pipeline_configuration.py index 8ce8aba..99f5a65 100644 --- a/streamer/pipeline_configuration.py +++ b/streamer/pipeline_configuration.py @@ -307,6 +307,9 @@ class PipelineConfig(configuration.Base): Must be true for live content. """ + generate_iframe_playlist = configuration.Field(bool, default=False).cast() + """If true, the iFrame playlist will be generated.""" + availability_window = configuration.Field(int, default=300).cast() """The number of seconds a segment remains available.""" From ad675b0032386baae5328d83f7add69d8d333243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Mon, 11 Nov 2024 13:03:21 +0100 Subject: [PATCH 2/2] Add iframe_ to the file name --- streamer/output_stream.py | 6 +++--- streamer/packager_node.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/streamer/output_stream.py b/streamer/output_stream.py index b76811c..fa5541e 100644 --- a/streamer/output_stream.py +++ b/streamer/output_stream.py @@ -90,9 +90,9 @@ def get_single_seg_file(self) -> Pipe: def get_identification(self) -> str: SINGLE_SEGMENT = { - MediaType.AUDIO: 'audio_{language}_{channels}c_{bitrate}_{codec}_{format}', - MediaType.VIDEO: 'video_{resolution_name}_{bitrate}_{codec}_{format}', - MediaType.TEXT: 'text_{language}_{format}', + MediaType.AUDIO: '{language}_{channels}c_{bitrate}_{codec}_{format}', + MediaType.VIDEO: '{resolution_name}_{bitrate}_{codec}_{format}', + MediaType.TEXT: '{language}_{format}', } return SINGLE_SEGMENT[self.type].format(**self.features) diff --git a/streamer/packager_node.py b/streamer/packager_node.py index 3625f38..2781dfe 100644 --- a/streamer/packager_node.py +++ b/streamer/packager_node.py @@ -142,7 +142,7 @@ def _setup_stream(self, stream: OutputStream) -> str: dict['hls_group_id'] = str(cast(AudioCodec, stream.codec).value) if stream.type == MediaType.VIDEO and self._pipeline_config.generate_iframe_playlist: - dict['iframe_playlist_name'] = stream.get_identification() + '.m3u8' + dict['iframe_playlist_name'] = 'iframe_' + stream.get_identification() + '.m3u8' if stream.input.drm_label: dict['drm_label'] = stream.input.drm_label