Allow user to set a max bitrate

This commit is contained in:
Jimi 2023-02-04 06:54:39 -07:00
parent 43d9c638e2
commit dbf5bc8dcb
3 changed files with 66 additions and 34 deletions

View File

@ -1026,8 +1026,16 @@
<translation>Limit Bitrate</translation>
</message>
<message>
<source>Enable or disable limiting video bitrates based on Roku's specifications.</source>
<translation>Enable or disable limiting video bitrates based on Roku's specifications.</translation>
<source>Enable or disable limiting video bitrates (based on the 'Playback Bitrate Limit' setting *or* Roku's specifications).</source>
<translation>Enable or disable limiting video bitrates (based on the 'Playback Bitrate Limit' setting *or* Roku's specifications).</translation>
</message>
<message>
<source>Playback Bitrate Limit</source>
<translation>Playback Bitrate Limit</translation>
</message>
<message>
<source>Max bitrate (MBPS) to use if 'Limit Bitrate' is enabled. If set to 0 limits will be per Roku's specifications.</source>
<translation>Max bitrate (MBPS) to use if 'Limit Bitrate' is enabled. If set to 0 limits will be per Roku's specifications.</translation>
</message>
<message>
<source>Libraries</source>

View File

@ -66,10 +66,17 @@
},
{
"title": "Limit Bitrate",
"description": "Enable or disable limiting video bitrates based on Roku's specifications.",
"description": "Enable or disable limiting video bitrates (based on the 'Playback Bitrate Limit' setting *or* Roku's specifications).",
"settingName": "playback.bitrate.maxlimited",
"type": "bool",
"default": "true"
},
{
"title": "Playback Bitrate Limit",
"description": "Max bitrate (MBPS) to use if 'Limit Bitrate' is enabled. If set to 0 limits will be per Roku's specifications.",
"settingName": "playback.bitrate.limit",
"type": "integer",
"default": "0"
}
]
},

View File

@ -252,6 +252,13 @@ function getDeviceProfile() as object
})
end if
print "DEBUG: "
for each item in deviceProfile.CodecProfiles
print item
for each condition in item.Conditions
print condition
end for
end for
return deviceProfile
end function
@ -360,44 +367,54 @@ function GetDirectPlayProfiles() as object
end function
function GetBitRateLimit(codec as string)
if get_user_setting("playback.bitrate.maxlimited") = "true"
' Some repeated values (e.g. same "40mbps" for several codecs)
' but this makes it easy to update in the future if the bitrates start to deviate.
if codec = "H264"
' Roku only supports h264 up to 10Mpbs
userSetLimit = get_user_setting("playback.bitrate.limit").ToInt()
userSetLimit *= 1000000
if userSetLimit > 0
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "10000000",
IsRequired: true
}
else if codec = "AV1"
' Roku only supports AV1 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
IsRequired: true
}
else if codec = "H265"
' Roku only supports h265 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
IsRequired: true
}
else if codec = "VP9"
' Roku only supports VP9 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
"Value": userSetLimit.ToStr(),
IsRequired: true
}
else
' Some repeated values (e.g. same "40mbps" for several codecs)
' but this makes it easy to update in the future if the bitrates start to deviate.
if codec = "H264"
' Roku only supports h264 up to 10Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "10000000",
IsRequired: true
}
else if codec = "AV1"
' Roku only supports AV1 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
IsRequired: true
}
else if codec = "H265"
' Roku only supports h265 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
IsRequired: true
}
else if codec = "VP9"
' Roku only supports VP9 up to 40Mpbs
return {
"Condition": "LessThanEqual",
"Property": "VideoBitrate",
"Value": "40000000",
IsRequired: true
}
end if
end if
end if
return {}
end function