Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'resolution': '624x352',
'codecs': 'avc1.4d001f, mp4a.40.5',
'subtitles': 'subs'},
media=[subtitles],
base_uri='http://example.com/'
)
high_playlist = m3u8.Playlist(
uri='video-1200k.m3u8',
stream_info={'bandwidth': 1200000,
'program_id': 1,
'codecs': 'avc1.4d001f, mp4a.40.5',
'subtitles': 'subs'},
media=[subtitles],
base_uri='http://example.com/'
)
low_iframe_playlist = m3u8.IFramePlaylist(
uri='video-800k-iframes.m3u8',
iframe_stream_info={'bandwidth': 151288,
'program_id': 1,
'closed_captions': None,
'resolution': '624x352',
'codecs': 'avc1.4d001f'},
base_uri='http://example.com/'
)
high_iframe_playlist = m3u8.IFramePlaylist(
uri='video-1200k-iframes.m3u8',
iframe_stream_info={'bandwidth': 193350,
'codecs': 'avc1.4d001f'},
base_uri='http://example.com/'
)
variant_m3u8.add_playlist(low_playlist)
'program_id': 1,
'codecs': 'avc1.4d001f, mp4a.40.5',
'subtitles': 'subs'},
media=[subtitles],
base_uri='http://example.com/'
)
low_iframe_playlist = m3u8.IFramePlaylist(
uri='video-800k-iframes.m3u8',
iframe_stream_info={'bandwidth': 151288,
'program_id': 1,
'closed_captions': None,
'resolution': '624x352',
'codecs': 'avc1.4d001f'},
base_uri='http://example.com/'
)
high_iframe_playlist = m3u8.IFramePlaylist(
uri='video-1200k-iframes.m3u8',
iframe_stream_info={'bandwidth': 193350,
'codecs': 'avc1.4d001f'},
base_uri='http://example.com/'
)
variant_m3u8.add_playlist(low_playlist)
variant_m3u8.add_playlist(high_playlist)
variant_m3u8.add_iframe_playlist(low_iframe_playlist)
variant_m3u8.add_iframe_playlist(high_iframe_playlist)
expected_content = """\
#EXTM3U
#EXT-X-MEDIA:URI="english_sub.m3u8",TYPE=SUBTITLES,GROUP-ID="subs",\
LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=800000,RESOLUTION=624x352,\
iframe_playlist.add_segment(iframe_segment)
total_bytes += s_bytes
total_duration += s_duration
if total_bytes != 0 and total_duration != 0:
iframe_bandwidth = str(int(total_bytes / total_duration * 8))
else:
return (None, None)
iframe_codecs = convert_codecs_for_iframes(playlist.stream_info.codecs)
stream_info = {'bandwidth': iframe_bandwidth,
'codecs': iframe_codecs}
iframe_playlist_uri = playlist.uri.replace('.m3u8', '-iframes.m3u8')
new_iframe_playlist = m3u8.IFramePlaylist(base_uri=playlist.base_uri,
uri=iframe_playlist_uri,
iframe_stream_info=stream_info)
return (new_iframe_playlist, {'uri': iframe_playlist_uri,
'content': iframe_playlist.dumps()})