Skip to content

Commit

Permalink
feat: Add generate_iframe_playlist option (shaka-project#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Nov 11, 2024
1 parent 96ae67a commit 071396b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit 071396b

Please sign in to comment.