diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9549bd13..62977ece 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.bs b/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.bs
index 1a2b7982..f73686e2 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.bs
@@ -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"
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.xml b/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.xml
index 3c9c25a3..6dc9d4c9 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.xml
+++ b/playlet-lib/src/components/Screens/SettingsScreen/QualitySelector/QualitySelector.xml
@@ -13,8 +13,8 @@
+ translation="[340,555]" />
+ translation="[496,555]" />
\ No newline at end of file
diff --git a/playlet-lib/src/components/Services/Dash/DashManifest.bs b/playlet-lib/src/components/Services/Dash/DashManifest.bs
index ef4f8b51..2750c2bd 100644
--- a/playlet-lib/src/components/Services/Dash/DashManifest.bs
+++ b/playlet-lib/src/components/Services/Dash/DashManifest.bs
@@ -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
diff --git a/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs b/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs
index 0e529e28..40210792 100644
--- a/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs
+++ b/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs
@@ -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"
diff --git a/playlet-lib/src/source/services/ApplicationInfo.bs b/playlet-lib/src/source/services/ApplicationInfo.bs
index 468233c1..a23ff4e2 100644
--- a/playlet-lib/src/source/services/ApplicationInfo.bs
+++ b/playlet-lib/src/source/services/ApplicationInfo.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
diff --git a/playlet-lib/src/source/utils/CodecCapabilities.bs b/playlet-lib/src/source/utils/CodecCapabilities.bs
new file mode 100644
index 00000000..7ec1ea21
--- /dev/null
+++ b/playlet-lib/src/source/utils/CodecCapabilities.bs
@@ -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
diff --git a/playlet-web/src/lib/Screens/Settings/SettingControls/EditQualityControl.svelte b/playlet-web/src/lib/Screens/Settings/SettingControls/EditQualityControl.svelte
index e68fb6a0..36f58cc8 100644
--- a/playlet-web/src/lib/Screens/Settings/SettingControls/EditQualityControl.svelte
+++ b/playlet-web/src/lib/Screens/Settings/SettingControls/EditQualityControl.svelte
@@ -1,17 +1,29 @@