mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Cap AVC profile level at 4.1 in stream master playlist (#41592)
* Cap AVC profile level at 4.1 * Use smaller multiplier in bandwidth calculation
This commit is contained in:
parent
6114006b8b
commit
9270585a44
@ -70,7 +70,8 @@ def get_codec_string(segment: io.BytesIO) -> str:
|
|||||||
):
|
):
|
||||||
profile = stsd_box[111:112].hex()
|
profile = stsd_box[111:112].hex()
|
||||||
compatibility = stsd_box[112:113].hex()
|
compatibility = stsd_box[112:113].hex()
|
||||||
level = stsd_box[113:114].hex()
|
# Cap level at 4.1 for compatibility with some Google Cast devices
|
||||||
|
level = hex(min(stsd_box[113], 41))[2:]
|
||||||
codec += "." + profile + compatibility + level
|
codec += "." + profile + compatibility + level
|
||||||
|
|
||||||
# Handle H265
|
# Handle H265
|
||||||
|
@ -32,10 +32,11 @@ class HlsMasterPlaylistView(StreamView):
|
|||||||
def render(track):
|
def render(track):
|
||||||
"""Render M3U8 file."""
|
"""Render M3U8 file."""
|
||||||
# Need to calculate max bandwidth as input_container.bit_rate doesn't seem to work
|
# Need to calculate max bandwidth as input_container.bit_rate doesn't seem to work
|
||||||
# Calculate file size / duration and use a multiplier to account for variation
|
# Calculate file size / duration and use a small multiplier to account for variation
|
||||||
|
# hls spec already allows for 25% variation
|
||||||
segment = track.get_segment(track.segments[-1])
|
segment = track.get_segment(track.segments[-1])
|
||||||
bandwidth = round(
|
bandwidth = round(
|
||||||
segment.segment.seek(0, io.SEEK_END) * 8 / segment.duration * 3
|
segment.segment.seek(0, io.SEEK_END) * 8 / segment.duration * 1.2
|
||||||
)
|
)
|
||||||
codecs = get_codec_string(segment.segment)
|
codecs = get_codec_string(segment.segment)
|
||||||
lines = [
|
lines = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user