4K support for AV1
This commit is contained in:
1 parent
35b38c7cd8
commit
ef83b598eb
8 files changed
+118
-23
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]
|
||||
|
||||
- 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
|
||||
|
||||
|
||||
+42
-5
@@ -1,5 +1,6 @@
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
|
||||
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
@@ -19,12 +20,48 @@ function Init()
|
||||
m.saveButton.observeField("buttonSelected", FuncName(OnSaveButtonSelected))
|
||||
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))
|
||||
|
||||
SetButtonPositions()
|
||||
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()
|
||||
saveButtonWidth = m.saveButton.width
|
||||
closeButtonWidth = m.closeButton.width
|
||||
@@ -99,16 +136,16 @@ function OnCheckedStateChange() as void
|
||||
|
||||
if autoChanged
|
||||
if hasAuto
|
||||
checkedState = [true, false, false, false, false, false, false]
|
||||
checkedState = NewCheckedState(true, false)
|
||||
m.lastCheckedState = checkedState
|
||||
m.checkList.checkedState = checkedState
|
||||
m.top.value = "auto"
|
||||
return
|
||||
else
|
||||
checkedState = [false, true, true, true, true, true, true]
|
||||
checkedState = NewCheckedState(false, true)
|
||||
m.lastCheckedState = checkedState
|
||||
m.checkList.checkedState = checkedState
|
||||
m.top.value = "1080p,720p,480p,360p,240p,144p"
|
||||
m.top.value = AllQualitiesValue()
|
||||
return
|
||||
end if
|
||||
end if
|
||||
@@ -128,7 +165,7 @@ function OnCheckedStateChange() as void
|
||||
end for
|
||||
|
||||
if values.Count() = 0
|
||||
checkedState = [true, false, false, false, false, false, false]
|
||||
checkedState = NewCheckedState(true, false)
|
||||
m.lastCheckedState = checkedState
|
||||
m.checkList.checkedState = checkedState
|
||||
m.top.value = "auto"
|
||||
|
||||
+4
-4
@@ -13,8 +13,8 @@
|
||||
</Rectangle>
|
||||
<Rectangle
|
||||
width="780"
|
||||
height="600"
|
||||
translation="[250,60]"
|
||||
height="640"
|
||||
translation="[250,40]"
|
||||
color="#242424">
|
||||
<CheckList
|
||||
id="checkList"
|
||||
@@ -43,13 +43,13 @@
|
||||
iconVisible="false"
|
||||
text="Save"
|
||||
padding="[30,30]"
|
||||
translation="[340,500]" />
|
||||
translation="[340,555]" />
|
||||
<ButtonEx
|
||||
id="closeButton"
|
||||
iconVisible="false"
|
||||
text="Close"
|
||||
padding="[30,30]"
|
||||
translation="[496,500]" />
|
||||
translation="[496,555]" />
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,5 +1,6 @@
|
||||
import "pkg:/components/Web/WebServer/Http/HttpUtils.bs"
|
||||
import "pkg:/source/services/XmlObject.bs"
|
||||
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.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
|
||||
' DashRouter cache keys on it without reading the prefs node. Set by DashRouter.
|
||||
public liveBackend as string = ""
|
||||
private canDecodeAv1Cache as dynamic
|
||||
|
||||
function new(invidiousInstance as string, disableAutoDubbed = false as boolean)
|
||||
m.invidiousInstance = invidiousInstance
|
||||
@@ -64,8 +66,11 @@ class DashManifest
|
||||
videoGroups = groupings.video
|
||||
|
||||
filteredVideoGroups = m.FilterVideoGroups(videoGroups, qualityFilter)
|
||||
if filteredVideoGroups.Count() = 0 and videoGroups.Count() > 0
|
||||
LogWarnNoTelemetry("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
|
||||
' The player skips video sets it can't play (webm container, undecodable codec).
|
||||
' 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
|
||||
end if
|
||||
|
||||
@@ -331,6 +336,30 @@ class DashManifest
|
||||
return filteredGroups
|
||||
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
|
||||
if qualityFilter.Count() = 0
|
||||
return true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
' Auto-generated file - do not modify manually
|
||||
' md5:1dc03998a561a4b1270454e10a4d7ead
|
||||
' md5:6966cee321cfa827e09c0f49b10a3fa8
|
||||
|
||||
import "pkg:/source/Protobuf/BinaryReader.bs"
|
||||
import "pkg:/source/Protobuf/BinaryWriter.bs"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/source/utils/CodecCapabilities.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
|
||||
class ApplicationInfo
|
||||
@@ -80,6 +81,7 @@ class ApplicationInfo
|
||||
user_country_code: m.roDeviceInfo.GetUserCountryCode()
|
||||
friendly_name: m.roDeviceInfo.GetFriendlyName()
|
||||
current_locale: m.roDeviceInfo.GetCurrentLocale()
|
||||
can_decode_av1: CodecCapabilities.CanDecodeAv1()
|
||||
}
|
||||
end if
|
||||
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,17 +1,29 @@
|
||||
<script lang="ts">
|
||||
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 qualityLabels = {
|
||||
auto: "Auto",
|
||||
"1080p": "1080p",
|
||||
"720p": "720p",
|
||||
"480p": "480p",
|
||||
"360p": "360p",
|
||||
"240p": "240p",
|
||||
"144p": "144p",
|
||||
};
|
||||
|
||||
function makeQualityLabels(canDecodeAv1: boolean) {
|
||||
return {
|
||||
auto: "Auto",
|
||||
...(canDecodeAv1 ? { "2160p": "2160p", "1440p": "1440p" } : {}),
|
||||
"1080p": "1080p",
|
||||
"720p": "720p",
|
||||
"480p": "480p",
|
||||
"360p": "360p",
|
||||
"240p": "240p",
|
||||
"144p": "144p",
|
||||
};
|
||||
}
|
||||
|
||||
let qualityLabels = makeQualityLabels(false);
|
||||
|
||||
playletStateStore.subscribe((state) => {
|
||||
qualityLabels = makeQualityLabels(
|
||||
(state.device || {})["can_decode_av1"] === true
|
||||
);
|
||||
});
|
||||
|
||||
export let displayText: string = "";
|
||||
export let key: string = "";
|
||||
|
||||
Reference in new issue
Block a user