Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add generate_iframe_playlist option #205

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions streamer/output_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: '{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)


class AudioOutputStream(OutputStream):

Expand Down
5 changes: 4 additions & 1 deletion streamer/packager_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'] = 'iframe_' + stream.get_identification() + '.m3u8'

if stream.input.drm_label:
dict['drm_label'] = stream.input.drm_label

Expand Down
3 changes: 3 additions & 0 deletions streamer/pipeline_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
Loading