Make our HLS master playlist spec compliant by adding bandwidth (#323)

Even though it's a complete guess.
pull/324/head
Mike Lang 2 years ago committed by GitHub
parent c7ed4cfc03
commit a6797aed19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,12 +9,24 @@ def generate_master(playlists):
Little validation or encoding is done - please try to keep the names valid
without escaping.
"""
# Canned bandwidth estimates based on the quality name,
# these may be entirely wrong but should be good enough.
# "source" and other unlisted names map to 1080p.
BANDWIDTHS = {
"1080p": 6846146,
"720p": 2373000,
"480p": 1427999,
"360p": 630000,
"160p": 230000,
}
lines = ["#EXTM3U"]
for name, url in playlists.items():
bandwidth = BANDWIDTHS.get(name, BANDWIDTHS["1080p"])
lines += [
# We name each variant with a VIDEO rendition with no url
'#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="{name}",NAME="{name}",AUTOSELECT=YES,DEFAULT=YES'.format(name=name),
'#EXT-X-STREAM-INF:VIDEO="{name}",NAME="{name}"'.format(name=name),
'#EXT-X-STREAM-INF:VIDEO="{name}",NAME="{name},BANDWIDTH={bandwidth}"'.format(name=name, bandwidth=bandwidth),
url,
]
return "\n".join(lines) + '\n'

Loading…
Cancel
Save