4K support for AV1
This commit is contained in:
1 parent
35b38c7cd8
commit
ef83b598eb
8 files changed
+110
-15
No files matched your search
+6
-1
@@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- Nothing worth mentioning yet.
|
### Added
|
||||||
|
|
||||||
|
- Support for 4K video
|
||||||
|
- Playlet already supported 4K videos. This adds a support check, and quality selectors in the settings, for the devices that support it.
|
||||||
|
- Not all 4k supporting devices - only with AV1 support (usually newer devices)
|
||||||
|
- Not all 4k videos are playable, only AV1 encoded videos
|
||||||
|
|
||||||
## [0.46.0] - 2026-06-12
|
## [0.46.0] - 2026-06-12
|
||||||
|
|
||||||
|
|||||||
+42
-5
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||||
|
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/MathUtils.bs"
|
import "pkg:/source/utils/MathUtils.bs"
|
||||||
import "pkg:/source/utils/RemoteKeys.bs"
|
import "pkg:/source/utils/RemoteKeys.bs"
|
||||||
@@ -19,12 +20,48 @@ function Init()
|
|||||||
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||||
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
m.closeButton.observeField("buttonSelected", FuncName(Close))
|
||||||
|
|
||||||
m.lastCheckedState = [false, false, false, false, false, false, false]
|
AddHighQualityOptions()
|
||||||
|
|
||||||
|
m.lastCheckedState = NewCheckedState(false, false)
|
||||||
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
m.checkList.observeField("checkedState", FuncName(OnCheckedStateChange))
|
||||||
|
|
||||||
SetButtonPositions()
|
SetButtonPositions()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
' 1440p/2160p exist on YouTube only as AV1 (mp4) and VP9 (webm) streams, and the
|
||||||
|
' player only plays fragmented MP4 in DASH, so the options only work with an AV1 decoder.
|
||||||
|
function AddHighQualityOptions() as void
|
||||||
|
if not CodecCapabilities.CanDecodeAv1()
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
content = m.checkList.content
|
||||||
|
for each quality in ["1440p", "2160p"]
|
||||||
|
node = CreateObject("roSGNode", "ContentNode")
|
||||||
|
node.id = quality
|
||||||
|
node.title = quality
|
||||||
|
content.insertChild(node, 1)
|
||||||
|
end for
|
||||||
|
end function
|
||||||
|
|
||||||
|
function NewCheckedState(autoChecked as boolean, othersChecked as boolean) as object
|
||||||
|
checkedState = [autoChecked]
|
||||||
|
count = m.checkList.content.getChildCount()
|
||||||
|
for i = 1 to count - 1
|
||||||
|
checkedState.push(othersChecked)
|
||||||
|
end for
|
||||||
|
return checkedState
|
||||||
|
end function
|
||||||
|
|
||||||
|
function AllQualitiesValue() as string
|
||||||
|
values = []
|
||||||
|
checkboxes = m.checkList.content.getChildren(-1, 0)
|
||||||
|
for i = 1 to checkboxes.Count() - 1
|
||||||
|
values.push(checkboxes[i].id)
|
||||||
|
end for
|
||||||
|
return values.Join(",")
|
||||||
|
end function
|
||||||
|
|
||||||
function SetButtonPositions()
|
function SetButtonPositions()
|
||||||
saveButtonWidth = m.saveButton.width
|
saveButtonWidth = m.saveButton.width
|
||||||
closeButtonWidth = m.closeButton.width
|
closeButtonWidth = m.closeButton.width
|
||||||
@@ -99,16 +136,16 @@ function OnCheckedStateChange() as void
|
|||||||
|
|
||||||
if autoChanged
|
if autoChanged
|
||||||
if hasAuto
|
if hasAuto
|
||||||
checkedState = [true, false, false, false, false, false, false]
|
checkedState = NewCheckedState(true, false)
|
||||||
m.lastCheckedState = checkedState
|
m.lastCheckedState = checkedState
|
||||||
m.checkList.checkedState = checkedState
|
m.checkList.checkedState = checkedState
|
||||||
m.top.value = "auto"
|
m.top.value = "auto"
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
checkedState = [false, true, true, true, true, true, true]
|
checkedState = NewCheckedState(false, true)
|
||||||
m.lastCheckedState = checkedState
|
m.lastCheckedState = checkedState
|
||||||
m.checkList.checkedState = checkedState
|
m.checkList.checkedState = checkedState
|
||||||
m.top.value = "1080p,720p,480p,360p,240p,144p"
|
m.top.value = AllQualitiesValue()
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
@@ -128,7 +165,7 @@ function OnCheckedStateChange() as void
|
|||||||
end for
|
end for
|
||||||
|
|
||||||
if values.Count() = 0
|
if values.Count() = 0
|
||||||
checkedState = [true, false, false, false, false, false, false]
|
checkedState = NewCheckedState(true, false)
|
||||||
m.lastCheckedState = checkedState
|
m.lastCheckedState = checkedState
|
||||||
m.checkList.checkedState = checkedState
|
m.checkList.checkedState = checkedState
|
||||||
m.top.value = "auto"
|
m.top.value = "auto"
|
||||||
|
|||||||
+4
-4
@@ -13,8 +13,8 @@
|
|||||||
</Rectangle>
|
</Rectangle>
|
||||||
<Rectangle
|
<Rectangle
|
||||||
width="780"
|
width="780"
|
||||||
height="600"
|
height="640"
|
||||||
translation="[250,60]"
|
translation="[250,40]"
|
||||||
color="#242424">
|
color="#242424">
|
||||||
<CheckList
|
<CheckList
|
||||||
id="checkList"
|
id="checkList"
|
||||||
@@ -43,13 +43,13 @@
|
|||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
text="Save"
|
text="Save"
|
||||||
padding="[30,30]"
|
padding="[30,30]"
|
||||||
translation="[340,500]" />
|
translation="[340,555]" />
|
||||||
<ButtonEx
|
<ButtonEx
|
||||||
id="closeButton"
|
id="closeButton"
|
||||||
iconVisible="false"
|
iconVisible="false"
|
||||||
text="Close"
|
text="Close"
|
||||||
padding="[30,30]"
|
padding="[30,30]"
|
||||||
translation="[496,500]" />
|
translation="[496,555]" />
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
||||||
import "pkg:/source/services/XmlObject.bs"
|
import "pkg:/source/services/XmlObject.bs"
|
||||||
|
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||||
import "pkg:/source/utils/Logging.bs"
|
import "pkg:/source/utils/Logging.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/UrlUtils.bs"
|
import "pkg:/source/utils/UrlUtils.bs"
|
||||||
@@ -14,6 +15,7 @@ class DashManifest
|
|||||||
' Backend the metadata came from, echoed onto every live-seg URL so the
|
' Backend the metadata came from, echoed onto every live-seg URL so the
|
||||||
' DashRouter cache keys on it without reading the prefs node. Set by DashRouter.
|
' DashRouter cache keys on it without reading the prefs node. Set by DashRouter.
|
||||||
public liveBackend as string = ""
|
public liveBackend as string = ""
|
||||||
|
private canDecodeAv1Cache as dynamic
|
||||||
|
|
||||||
function new(invidiousInstance as string, disableAutoDubbed = false as boolean)
|
function new(invidiousInstance as string, disableAutoDubbed = false as boolean)
|
||||||
m.invidiousInstance = invidiousInstance
|
m.invidiousInstance = invidiousInstance
|
||||||
@@ -64,8 +66,11 @@ class DashManifest
|
|||||||
videoGroups = groupings.video
|
videoGroups = groupings.video
|
||||||
|
|
||||||
filteredVideoGroups = m.FilterVideoGroups(videoGroups, qualityFilter)
|
filteredVideoGroups = m.FilterVideoGroups(videoGroups, qualityFilter)
|
||||||
if filteredVideoGroups.Count() = 0 and videoGroups.Count() > 0
|
' The player skips video sets it can't play (webm container, undecodable codec).
|
||||||
LogWarnNoTelemetry("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
|
' A filter that leaves only such sets - e.g. 2160p-only when the 4K streams are
|
||||||
|
' VP9/webm - would play audio with no video, so fall back to all streams.
|
||||||
|
if not m.HasPlayableVideoGroup(filteredVideoGroups) and videoGroups.Count() > 0
|
||||||
|
LogWarnNoTelemetry("No playable video streams using quality filter:", qualityFilter, "Falling back to all video streams")
|
||||||
filteredVideoGroups = videoGroups
|
filteredVideoGroups = videoGroups
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -331,6 +336,30 @@ class DashManifest
|
|||||||
return filteredGroups
|
return filteredGroups
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function HasPlayableVideoGroup(videoGroups as object) as boolean
|
||||||
|
for each group in videoGroups
|
||||||
|
mimeType = ValidString(group[0].type)
|
||||||
|
' DASH chunks must be fragmented MP4: the player never picks webm sets.
|
||||||
|
if not mimeType.startsWith("video/mp4")
|
||||||
|
continue for
|
||||||
|
end if
|
||||||
|
if mimeType.inStr("avc1") <> -1
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
if mimeType.inStr("av01") <> -1 and m.CanDecodeAv1()
|
||||||
|
return true
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
return false
|
||||||
|
end function
|
||||||
|
|
||||||
|
function CanDecodeAv1() as boolean
|
||||||
|
if m.canDecodeAv1Cache = invalid
|
||||||
|
m.canDecodeAv1Cache = CodecCapabilities.CanDecodeAv1()
|
||||||
|
end if
|
||||||
|
return m.canDecodeAv1Cache
|
||||||
|
end function
|
||||||
|
|
||||||
function IsVideoFormatIncluded(stream as object, qualityFilter as object) as boolean
|
function IsVideoFormatIncluded(stream as object, qualityFilter as object) as boolean
|
||||||
if qualityFilter.Count() = 0
|
if qualityFilter.Count() = 0
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
' Auto-generated file - do not modify manually
|
' Auto-generated file - do not modify manually
|
||||||
' md5:1dc03998a561a4b1270454e10a4d7ead
|
' md5:6966cee321cfa827e09c0f49b10a3fa8
|
||||||
|
|
||||||
import "pkg:/source/Protobuf/BinaryReader.bs"
|
import "pkg:/source/Protobuf/BinaryReader.bs"
|
||||||
import "pkg:/source/Protobuf/BinaryWriter.bs"
|
import "pkg:/source/Protobuf/BinaryWriter.bs"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
class ApplicationInfo
|
class ApplicationInfo
|
||||||
@@ -80,6 +81,7 @@ class ApplicationInfo
|
|||||||
user_country_code: m.roDeviceInfo.GetUserCountryCode()
|
user_country_code: m.roDeviceInfo.GetUserCountryCode()
|
||||||
friendly_name: m.roDeviceInfo.GetFriendlyName()
|
friendly_name: m.roDeviceInfo.GetFriendlyName()
|
||||||
current_locale: m.roDeviceInfo.GetCurrentLocale()
|
current_locale: m.roDeviceInfo.GetCurrentLocale()
|
||||||
|
can_decode_av1: CodecCapabilities.CanDecodeAv1()
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
return m.deviceInfo
|
return m.deviceInfo
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace CodecCapabilities
|
||||||
|
' YouTube serves streams above 1080p only as AV1 (mp4) and VP9 (webm), and the
|
||||||
|
' player only plays fragmented MP4 in DASH - so AV1 decoding is what decides
|
||||||
|
' whether the device can play 4K.
|
||||||
|
function CanDecodeAv1() as boolean
|
||||||
|
devInfo = CreateObject("roDeviceInfo")
|
||||||
|
canDecode = devInfo.CanDecodeVideo({ "codec": "av1" })
|
||||||
|
return canDecode.result = true
|
||||||
|
end function
|
||||||
|
end namespace
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PlayletApi } from "lib/Api/PlayletApi";
|
import { PlayletApi } from "lib/Api/PlayletApi";
|
||||||
import { translate, userPreferencesStore } from "lib/Stores";
|
import { playletStateStore, translate, userPreferencesStore } from "lib/Stores";
|
||||||
|
|
||||||
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
|
||||||
const qualityLabels = {
|
|
||||||
|
function makeQualityLabels(canDecodeAv1: boolean) {
|
||||||
|
return {
|
||||||
auto: "Auto",
|
auto: "Auto",
|
||||||
|
...(canDecodeAv1 ? { "2160p": "2160p", "1440p": "1440p" } : {}),
|
||||||
"1080p": "1080p",
|
"1080p": "1080p",
|
||||||
"720p": "720p",
|
"720p": "720p",
|
||||||
"480p": "480p",
|
"480p": "480p",
|
||||||
@@ -12,6 +15,15 @@
|
|||||||
"240p": "240p",
|
"240p": "240p",
|
||||||
"144p": "144p",
|
"144p": "144p",
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let qualityLabels = makeQualityLabels(false);
|
||||||
|
|
||||||
|
playletStateStore.subscribe((state) => {
|
||||||
|
qualityLabels = makeQualityLabels(
|
||||||
|
(state.device || {})["can_decode_av1"] === true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
export let displayText: string = "";
|
export let displayText: string = "";
|
||||||
export let key: string = "";
|
export let key: string = "";
|
||||||
|
|||||||
Reference in new issue
Block a user