Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0270cd1bc1 | ||
|
|
08cbef83a3 | ||
|
|
c25e40070a |
+31
-11
@@ -890,28 +890,48 @@ enableautobitratebitrate-Video-<true|false> = false ← 上游拼写,bitra
|
||||
1. **续播点 33:22.759 的来历**:就是 2026-10-05 那次转码会话留下的(`stopped ... at 2002759ms`)。所以 10-17 两次播放都从 33:22 续播,画面出不来进度自然不动,于是「停在 33:22」重复了两次。
|
||||
2. **文件本身没问题**:完全分配无空洞(`du` 实际用量 == 表观大小)、`moov` 在文件头(faststart 正常)、33:22 处 ffmpeg 解码无报错、Jellyfin 数据库里时长正确(50:58)。同目录还有 3 个垃圾广告文件(`.url` × 3 + 一个 20 MB 的 `三 上 悠 亚…mp4`),是盗版站打包进来的。
|
||||
|
||||
### 18.7 已做(插件 0.3.0.0 / bundle `4e9a8f`)
|
||||
### 18.7 已做(插件 0.5.0.0 / bundle `72681d`)
|
||||
|
||||
- [x] `src/00-core.js` 的能力探测补上 Main 10 和 8K/4K 分档;新增 `NS.caps.codec`(`decodingInfo` 逐档结果)与 `NS.capsDiag()` 里的 `HEVC real` 段
|
||||
- [x] **彻底自动化**:用 `MediaCapabilities.decodingInfo` 真机探测后覆盖 `HTMLVideoElement.prototype.canPlayType`,让 Jellyfin Web 自己那套 `maxHevcLevel` 逻辑算出准确 profile
|
||||
- [x] **补上「实时吞吐」这一维**(`smooth`)—— 见下
|
||||
|
||||
覆盖逻辑的关键点:
|
||||
|
||||
- 每档在**它对应的分辨率**上探测(level 字符串不带尺寸):`L120→1920x1080@30`、`L123→1080p60`、`L153→3840x2160@60`、`L183/L186→8192x4096@60`
|
||||
- 每档在**它对应的分辨率和码率**上探测(level 字符串不带尺寸):`L120→1920x1080@30/8Mbps`、`L123→1080p60/8Mbps`、`L153→3840x2160@60/20Mbps`、`L183/L186→8192x4096@60/30Mbps`
|
||||
- codec string → `'<profile_idc>:<level>'`(`hvc1.2.4.L183` → `2:183`);`hvc1`/`hev1` 同键,因为差的只是 sample entry
|
||||
- **只有 `supported === false` 才降级**;`supported:true, smooth:false` 只记录不行动(太贴边,而且看门狗已经兜底)
|
||||
- **拦掉一档的两个条件**:`supported === false`(完全解不了)或 **`smooth === false`**(能解但跟不上)。只有 `powerEfficient:false`(纯软解)本身不拦
|
||||
- 钩子在 bundle 执行时**同步**装上(此时还没有 verdict,一律交给原生),探测结果落地后才生效
|
||||
- 逃生开关:`localStorage['jfvr-cpt'] = 'off'` → 完全不装钩子
|
||||
- 逃生开关:`localStorage['jfvr-cpt'] = 'off'` 完全关掉;`localStorage['jfvr-cpt-keep'] = '2:183'` 只保留某一档(单台设备误报时用)
|
||||
|
||||
三种模式本地实测(`_harness-codec.html`,全过):
|
||||
### 18.7.1 为什么最后把 `smooth` 加上了(重要)
|
||||
|
||||
| 模式 | 结果 |
|
||||
|---|---|
|
||||
| `pc` | 8K Main10 被拦 → Jellyfin 封顶 level 153 → 8K 文件超出声明 → **转码** |
|
||||
| `quest` | 无一被拦 → 声明保持 ≥183 → **Direct Play 不变** |
|
||||
| `off` | 钩子未安装,`canPlayType` 完全未动 → 恢复旧行为 |
|
||||
0.3.0.0 只看了 `supported`,当时故意不动 `smooth`,理由是怕误伤 Quest。但那样会漏掉**最现实的那种桌面场景**:
|
||||
|
||||
> 显卡**有** HEVC 解码器(所以 `canPlayType` 报 "probably"、`supported:true`),但**在 8K60 下跑不动**(`smooth:false`)
|
||||
|
||||
结果就是:声称支持 level 6.1 → 服务器 DirectPlay → 黑屏。而这恰好就是本机上那个文件的真实情况。所以 0.5.0.0 把它纳入判定。
|
||||
|
||||
**定位真机问题时看这个**:在出问题的浏览器控制台跑
|
||||
|
||||
```js
|
||||
window.__JFVR.capsDiag()
|
||||
```
|
||||
|
||||
会列出每一档的 `supported / smooth / powerEfficient`、探测用的负载、以及**为什么被拦**(`unsupported` 还是 `not-smooth`)。一次就能看出是哪一维的问题。
|
||||
|
||||
五种模式本地实测(`_harness-codec.html`,全过):
|
||||
|
||||
| 模式 | 模拟 | 结果 |
|
||||
|---|---|---|
|
||||
| `pc` | `supported=false` | 封顶 level 153 → **转码** |
|
||||
| `slow` | `supported=true, smooth=false`(**真实桌面场景**) | 封顶 level 153 → **转码** |
|
||||
| `quest` | 全部 `smooth` | 保持 ≥183 → **Direct Play** |
|
||||
| `pin` | `slow` + `jfvr-cpt-keep=2:183` | 恢复 183 → **Direct Play** |
|
||||
| `off` | 开关关闭 | `canPlayType` 完全未动 |
|
||||
|
||||
### 18.8 待办
|
||||
|
||||
- [ ] 探测目前只覆盖 HEVC。AV1 / VP9 走同一套机制,但库里没有这类片源,先不做。
|
||||
- [ ] `decodingInfo` 的 `smooth` 现在是只记录不行动。如果哪天出现「supported:true 但实际掉帧」的案例,可以考虑把 `smooth === false` 也纳入降级条件(风险:可能误伤 Quest)。
|
||||
- [ ] 网络带宽那一维不在设备档案范围内(档案是在播放开始时判一次的)。Jellyfin 自带的 Auto 码率探测管这个。
|
||||
- [ ] 看门狗(§1.2)现在退居为纯兜底:如果检测结果准了,它就不应该再触发。它仍然保留,作为「声称能播结果没播出来」的最后一道。
|
||||
|
||||
@@ -109,25 +109,43 @@ if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
|
||||
|
||||
插件的做法:
|
||||
|
||||
1. 页面加载时用 **`MediaCapabilities.decodingInfo`** 对 HEVC 各档做真机探测(每档在它对应的分辨率上测:L120→1080p30、L153→4K60、L183/L186→8K60,因为 level 字符串本身不带尺寸);
|
||||
2. 把结果回灌给 `HTMLVideoElement.prototype.canPlayType`:只有 `supported === false` 才返回 `''`,其余全部交给原生实现。
|
||||
1. 页面加载时用 **`MediaCapabilities.decodingInfo`** 对 HEVC 各档做真机探测(每档在它对应的分辨率和码率上测:L120→1080p30/8Mbps、L153→4K60/20Mbps、L183/L186→8K60/30Mbps,因为 level 字符串本身不带尺寸);
|
||||
2. 把结果回灌给 `HTMLVideoElement.prototype.canPlayType`。
|
||||
|
||||
**拦掉一档的条件有两个,都是「确定的不能」**:
|
||||
|
||||
| 条件 | 含义 |
|
||||
|---|---|
|
||||
| `supported === false` | 完全解不了这个格式 |
|
||||
| `smooth === false` | 能解,但**在那种分辨率和帧率下跟不上** —— 就是「有 HEVC 解码器,但 8K 跑不动」这种桌面场景 |
|
||||
|
||||
只有 `powerEfficient:false`(纯软解)**本身不拦**。
|
||||
|
||||
这样 Jellyfin Web 自己那套 `maxHevcLevel` 逻辑就会得出**准确**档案:
|
||||
|
||||
| 设备 | 结果 |
|
||||
|---|---|
|
||||
| 桌面(声称支持但实际解不动 8K Main 10) | 降到 level 153 → 8K 文件超出声明 → **服务器转码** |
|
||||
| 桌面(声称支持但实际解不动 8K Main 10) | 降到 level 153 → 8K 文件超出声明 → **服务器自动转码** |
|
||||
| Quest 3(真能解 8K Main 10) | 保持 ≥183 → **继续 Direct Play** |
|
||||
|
||||
**故意保守**:只有 `supported === false` 才降级。`supported:true, smooth:false` 会记录但不影响行为 —— 太贴边了,而且「声称能播结果没播出来」已经有 §1.2 的看门狗兜底。
|
||||
注意:这里**不问用户任何东西**。客户端如实上报,Jellyfin 在 `PlaybackInfo` 那一步自己选 Transcode —— 这正是「提示用户切码率」想要达到的目的,只是做在了正确的层。
|
||||
|
||||
出问题的逃生开关(某台设备报得离谱时用):
|
||||
逃生开关:
|
||||
|
||||
```js
|
||||
localStorage['jfvr-cpt'] = 'off'; // 然后刷新,覆盖完全不安装
|
||||
localStorage['jfvr-cpt'] = 'off'; // 完全关掉钩子
|
||||
localStorage['jfvr-cpt-keep'] = '2:183'; // 只保留某一档(单台设备误报时用,不用整个关掉)
|
||||
```
|
||||
|
||||
当前状态可以在诊断面板里看到(`canPlayType hook` 和 `HEVC real (decodingInfo)` 两段)。这也是 Meta 官方文档推荐的做法 —— 他们明确说「用 Media Capabilities API 探测,不要靠 UA 嗅探」。
|
||||
当前状态可以在诊断面板里看到,每档会写明**为什么**被拦(`unsupported` / `not-smooth`)或是否被 pin:
|
||||
|
||||
```
|
||||
canPlayType hook : on (blocked: Main10 L6.1 (8K) (not-smooth), ...)
|
||||
HEVC real (decodingInfo):
|
||||
Main10 L6.1 (8K) supported=true smooth=false powerEfficient=true [8192x4096@60 30Mbps] <-- BLOCKED (not-smooth)
|
||||
```
|
||||
|
||||
这也是 Meta 官方文档推荐的做法 —— 他们明确说「用 Media Capabilities API 探测,不要靠 UA 嗅探」。
|
||||
|
||||
### 1.4 「VR 播放」按钮可以拖了
|
||||
|
||||
|
||||
Vendored
+63
-23
@@ -320,6 +320,7 @@
|
||||
/* MediaCapabilities verdicts, keyed '<profile_idc>:<level>'. See below. */
|
||||
codec: {},
|
||||
codecBlocked: [],
|
||||
codecKept: [],
|
||||
cptPatched: false,
|
||||
cptMode: null
|
||||
};
|
||||
@@ -359,24 +360,32 @@
|
||||
* DirectPlay. Meta's browser-video docs recommend exactly this API over UA
|
||||
* sniffing.
|
||||
*
|
||||
* Only `supported === false` downgrades. `supported:true, smooth:false` is
|
||||
* recorded but does not change behaviour: it is too close to the edge to act
|
||||
* on, and 40-watchdog.js already covers "it claimed to work and did not".
|
||||
* Only a definite "no" downgrades, but "no" has two shapes and both matter:
|
||||
*
|
||||
* Kill switch if a device reports nonsense:
|
||||
* localStorage['jfvr-cpt'] = 'off' then reload
|
||||
* supported === false the decoder cannot handle the format at all
|
||||
* smooth === false it can, but not in real time at that resolution and
|
||||
* frame rate -- the case a desktop with a small HEVC
|
||||
* decoder hits on 8K, where the picture never appears
|
||||
* even though the codec is "supported"
|
||||
*
|
||||
* Either one means the server should transcode. A tier that is only
|
||||
* `powerEfficient:false` (software decode) is NOT acted on by itself.
|
||||
*
|
||||
* Escape hatches, if a device reports nonsense:
|
||||
* localStorage['jfvr-cpt'] = 'off' disable the hook entirely
|
||||
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
||||
*/
|
||||
|
||||
// decodingInfo needs real dimensions; a level string does not carry them, so
|
||||
// each level is probed at the resolution it exists for.
|
||||
// each level is probed at the resolution and bitrate it exists for.
|
||||
var CODEC_PROBES = [
|
||||
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, codec: 'hvc1.1.L120' },
|
||||
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.1.4.L123' },
|
||||
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.1.6.L183.B0' },
|
||||
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.2.4.L123' },
|
||||
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, codec: 'hvc1.2.4.L153' },
|
||||
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L183' },
|
||||
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L186' }
|
||||
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, mbps: 8, codec: 'hvc1.1.L120' },
|
||||
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.1.4.L123' },
|
||||
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.1.6.L183.B0' },
|
||||
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.2.4.L123' },
|
||||
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, mbps: 20, codec: 'hvc1.2.4.L153' },
|
||||
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.2.4.L183' },
|
||||
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.2.4.L186' }
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -427,11 +436,34 @@
|
||||
* MediaCapabilities probe + canPlayType override
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
/** Tiers the user has pinned as "keep claiming this", '<key>,<key>' in localStorage. */
|
||||
function readKeepList() {
|
||||
try {
|
||||
var raw = localStorage.getItem('jfvr-cpt-keep') || '';
|
||||
return raw.split(',').map(function (s) { return s.trim(); }).filter(Boolean);
|
||||
} catch (e) { return []; }
|
||||
}
|
||||
|
||||
/** Why a verdict means "do not claim this tier", or null if it is fine. */
|
||||
function blockReason(v, keep) {
|
||||
if (!v || v.error) return null; // unknown -> leave it to the browser
|
||||
if (keep.indexOf(v.key) >= 0) return null; // user pinned it
|
||||
if (v.supported === false) return 'unsupported';
|
||||
if (v.smooth === false) return 'not-smooth';
|
||||
return null;
|
||||
}
|
||||
|
||||
function applyVerdicts() {
|
||||
NS.caps.codecBlocked = CODEC_PROBES.filter(function (p) {
|
||||
var keep = readKeepList();
|
||||
NS.caps.codecKept = [];
|
||||
NS.caps.codecBlocked = [];
|
||||
CODEC_PROBES.forEach(function (p) {
|
||||
var v = NS.caps.codec[p.key];
|
||||
return v && v.supported === false;
|
||||
}).map(function (p) { return p.name; });
|
||||
if (!v) return;
|
||||
var why = blockReason(v, keep);
|
||||
if (why) NS.caps.codecBlocked.push(p.name + ' (' + why + ')');
|
||||
else if (keep.indexOf(p.key) >= 0) NS.caps.codecKept.push(p.name);
|
||||
});
|
||||
}
|
||||
|
||||
function installCanPlayTypeOverride() {
|
||||
@@ -445,7 +477,7 @@
|
||||
var key = hevcKey(type);
|
||||
var v = key && NS.caps.codec[key];
|
||||
// Only a definite "no" is acted on. Anything else is the browser's call.
|
||||
if (v && v.supported === false) return '';
|
||||
if (v && blockReason(v, NS.caps.__keep || [])) return '';
|
||||
} catch (e) { /* never break the native answer */ }
|
||||
return orig.apply(this, arguments);
|
||||
};
|
||||
@@ -461,6 +493,10 @@
|
||||
var mc = navigator.mediaCapabilities;
|
||||
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
||||
|
||||
// Read the pin list once, up front: canPlayType is synchronous and must not
|
||||
// touch localStorage on every call.
|
||||
NS.caps.__keep = readKeepList();
|
||||
|
||||
// Install FIRST, synchronously, so the hook is in place before anything can
|
||||
// read canPlayType. Until a verdict lands the hook just defers to native,
|
||||
// which is the safe default.
|
||||
@@ -472,20 +508,21 @@
|
||||
type: 'file',
|
||||
video: {
|
||||
contentType: 'video/mp4; codecs="' + p.codec + '"',
|
||||
width: p.w, height: p.h, bitrate: 20000000, framerate: p.fps
|
||||
width: p.w, height: p.h, bitrate: p.mbps * 1000000, framerate: p.fps
|
||||
}
|
||||
};
|
||||
mc.decodingInfo(cfg).then(function (info) {
|
||||
NS.caps.codec[p.key] = {
|
||||
name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps,
|
||||
key: p.key, name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps + ' ' + p.mbps + 'Mbps',
|
||||
supported: info.supported, smooth: info.smooth, powerEfficient: info.powerEfficient
|
||||
};
|
||||
}).catch(function (e) {
|
||||
NS.caps.codec[p.key] = { name: p.name, error: String(e && e.message || e) };
|
||||
NS.caps.codec[p.key] = { key: p.key, name: p.name, error: String(e && e.message || e) };
|
||||
}).then(function () {
|
||||
if (--pending === 0) {
|
||||
applyVerdicts();
|
||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none'));
|
||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none') +
|
||||
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -493,13 +530,16 @@
|
||||
|
||||
NS.capsDiag = function () {
|
||||
var c = NS.caps;
|
||||
var keep = readKeepList();
|
||||
var real = CODEC_PROBES.map(function (p) {
|
||||
var v = c.codec[p.key];
|
||||
if (!v) return ' ' + p.name.padEnd(20) + ' (pending)';
|
||||
if (v.error) return ' ' + p.name.padEnd(20) + ' error: ' + v.error;
|
||||
var why = blockReason(v, keep);
|
||||
return ' ' + p.name.padEnd(20) + ' supported=' + v.supported +
|
||||
' smooth=' + v.smooth + ' powerEfficient=' + v.powerEfficient +
|
||||
' [' + v.workload + ']' + (v.supported === false ? ' <-- BLOCKED' : '');
|
||||
' [' + v.workload + ']' +
|
||||
(why ? ' <-- BLOCKED (' + why + ')' : (keep.indexOf(p.key) >= 0 ? ' <-- pinned' : ''));
|
||||
}).join('\n');
|
||||
|
||||
return [
|
||||
@@ -513,7 +553,7 @@
|
||||
'MAX_TEXTURE_SIZE : ' + c.maxTextureSize,
|
||||
'HEVC canPlayType : ' + JSON.stringify(c.hevc),
|
||||
'canPlayType hook : ' + (c.cptMode || 'pending') +
|
||||
(c.cptMode === 'on' ? ' (downgraded: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
|
||||
(c.cptMode === 'on' ? ' (blocked: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
|
||||
'HEVC real (decodingInfo):',
|
||||
real
|
||||
].join('\n');
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
"owner": "cat-shark",
|
||||
"category": "General",
|
||||
"versions": [
|
||||
{
|
||||
"version": "0.5.0.0",
|
||||
"targetAbi": "12.0.0.0",
|
||||
"changelog": "Bundle version: `72681d`\n\nFirst plugin build. The web bundle is embedded in the DLL and served from /JFVR/jfvr.js; index.html is rewritten at request time, so nothing is written to the jellyfin-web folder on disk.",
|
||||
"sourceUrl": "https://git.cat-shark.xyz/cat-shark/jellyfin_vr_web_plugin/releases/download/v0.5.0.0/Jellyfin.Plugin.JFVR_12.0.0.0.zip",
|
||||
"checksum": "F9773C70C9CC4858AF042E40D5CFBAA9",
|
||||
"timestamp": "2026-10-17T17:34:28"
|
||||
},
|
||||
{
|
||||
"version": "0.4.0.0",
|
||||
"targetAbi": "12.0.0.0",
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
# (InstallationManager.GetAvailablePackages), so one package covers all of 12.x.
|
||||
name: "Jellyfin Web VR"
|
||||
guid: "7d33ef59-f9b0-412b-93bd-5cd5353018de"
|
||||
version: "0.4.0.0"
|
||||
version: "0.5.0.0"
|
||||
targetAbi: "12.0.0.0"
|
||||
framework: "net10.0"
|
||||
overview: "VR180/VR360 playback inside Jellyfin Web for Meta Quest 3."
|
||||
|
||||
+63
-23
@@ -312,6 +312,7 @@
|
||||
/* MediaCapabilities verdicts, keyed '<profile_idc>:<level>'. See below. */
|
||||
codec: {},
|
||||
codecBlocked: [],
|
||||
codecKept: [],
|
||||
cptPatched: false,
|
||||
cptMode: null
|
||||
};
|
||||
@@ -351,24 +352,32 @@
|
||||
* DirectPlay. Meta's browser-video docs recommend exactly this API over UA
|
||||
* sniffing.
|
||||
*
|
||||
* Only `supported === false` downgrades. `supported:true, smooth:false` is
|
||||
* recorded but does not change behaviour: it is too close to the edge to act
|
||||
* on, and 40-watchdog.js already covers "it claimed to work and did not".
|
||||
* Only a definite "no" downgrades, but "no" has two shapes and both matter:
|
||||
*
|
||||
* Kill switch if a device reports nonsense:
|
||||
* localStorage['jfvr-cpt'] = 'off' then reload
|
||||
* supported === false the decoder cannot handle the format at all
|
||||
* smooth === false it can, but not in real time at that resolution and
|
||||
* frame rate -- the case a desktop with a small HEVC
|
||||
* decoder hits on 8K, where the picture never appears
|
||||
* even though the codec is "supported"
|
||||
*
|
||||
* Either one means the server should transcode. A tier that is only
|
||||
* `powerEfficient:false` (software decode) is NOT acted on by itself.
|
||||
*
|
||||
* Escape hatches, if a device reports nonsense:
|
||||
* localStorage['jfvr-cpt'] = 'off' disable the hook entirely
|
||||
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
||||
*/
|
||||
|
||||
// decodingInfo needs real dimensions; a level string does not carry them, so
|
||||
// each level is probed at the resolution it exists for.
|
||||
// each level is probed at the resolution and bitrate it exists for.
|
||||
var CODEC_PROBES = [
|
||||
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, codec: 'hvc1.1.L120' },
|
||||
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.1.4.L123' },
|
||||
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.1.6.L183.B0' },
|
||||
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.2.4.L123' },
|
||||
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, codec: 'hvc1.2.4.L153' },
|
||||
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L183' },
|
||||
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L186' }
|
||||
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, mbps: 8, codec: 'hvc1.1.L120' },
|
||||
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.1.4.L123' },
|
||||
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.1.6.L183.B0' },
|
||||
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, mbps: 8, codec: 'hvc1.2.4.L123' },
|
||||
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, mbps: 20, codec: 'hvc1.2.4.L153' },
|
||||
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.2.4.L183' },
|
||||
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, mbps: 30, codec: 'hvc1.2.4.L186' }
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -419,11 +428,34 @@
|
||||
* MediaCapabilities probe + canPlayType override
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
/** Tiers the user has pinned as "keep claiming this", '<key>,<key>' in localStorage. */
|
||||
function readKeepList() {
|
||||
try {
|
||||
var raw = localStorage.getItem('jfvr-cpt-keep') || '';
|
||||
return raw.split(',').map(function (s) { return s.trim(); }).filter(Boolean);
|
||||
} catch (e) { return []; }
|
||||
}
|
||||
|
||||
/** Why a verdict means "do not claim this tier", or null if it is fine. */
|
||||
function blockReason(v, keep) {
|
||||
if (!v || v.error) return null; // unknown -> leave it to the browser
|
||||
if (keep.indexOf(v.key) >= 0) return null; // user pinned it
|
||||
if (v.supported === false) return 'unsupported';
|
||||
if (v.smooth === false) return 'not-smooth';
|
||||
return null;
|
||||
}
|
||||
|
||||
function applyVerdicts() {
|
||||
NS.caps.codecBlocked = CODEC_PROBES.filter(function (p) {
|
||||
var keep = readKeepList();
|
||||
NS.caps.codecKept = [];
|
||||
NS.caps.codecBlocked = [];
|
||||
CODEC_PROBES.forEach(function (p) {
|
||||
var v = NS.caps.codec[p.key];
|
||||
return v && v.supported === false;
|
||||
}).map(function (p) { return p.name; });
|
||||
if (!v) return;
|
||||
var why = blockReason(v, keep);
|
||||
if (why) NS.caps.codecBlocked.push(p.name + ' (' + why + ')');
|
||||
else if (keep.indexOf(p.key) >= 0) NS.caps.codecKept.push(p.name);
|
||||
});
|
||||
}
|
||||
|
||||
function installCanPlayTypeOverride() {
|
||||
@@ -437,7 +469,7 @@
|
||||
var key = hevcKey(type);
|
||||
var v = key && NS.caps.codec[key];
|
||||
// Only a definite "no" is acted on. Anything else is the browser's call.
|
||||
if (v && v.supported === false) return '';
|
||||
if (v && blockReason(v, NS.caps.__keep || [])) return '';
|
||||
} catch (e) { /* never break the native answer */ }
|
||||
return orig.apply(this, arguments);
|
||||
};
|
||||
@@ -453,6 +485,10 @@
|
||||
var mc = navigator.mediaCapabilities;
|
||||
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
||||
|
||||
// Read the pin list once, up front: canPlayType is synchronous and must not
|
||||
// touch localStorage on every call.
|
||||
NS.caps.__keep = readKeepList();
|
||||
|
||||
// Install FIRST, synchronously, so the hook is in place before anything can
|
||||
// read canPlayType. Until a verdict lands the hook just defers to native,
|
||||
// which is the safe default.
|
||||
@@ -464,20 +500,21 @@
|
||||
type: 'file',
|
||||
video: {
|
||||
contentType: 'video/mp4; codecs="' + p.codec + '"',
|
||||
width: p.w, height: p.h, bitrate: 20000000, framerate: p.fps
|
||||
width: p.w, height: p.h, bitrate: p.mbps * 1000000, framerate: p.fps
|
||||
}
|
||||
};
|
||||
mc.decodingInfo(cfg).then(function (info) {
|
||||
NS.caps.codec[p.key] = {
|
||||
name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps,
|
||||
key: p.key, name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps + ' ' + p.mbps + 'Mbps',
|
||||
supported: info.supported, smooth: info.smooth, powerEfficient: info.powerEfficient
|
||||
};
|
||||
}).catch(function (e) {
|
||||
NS.caps.codec[p.key] = { name: p.name, error: String(e && e.message || e) };
|
||||
NS.caps.codec[p.key] = { key: p.key, name: p.name, error: String(e && e.message || e) };
|
||||
}).then(function () {
|
||||
if (--pending === 0) {
|
||||
applyVerdicts();
|
||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none'));
|
||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none') +
|
||||
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -485,13 +522,16 @@
|
||||
|
||||
NS.capsDiag = function () {
|
||||
var c = NS.caps;
|
||||
var keep = readKeepList();
|
||||
var real = CODEC_PROBES.map(function (p) {
|
||||
var v = c.codec[p.key];
|
||||
if (!v) return ' ' + p.name.padEnd(20) + ' (pending)';
|
||||
if (v.error) return ' ' + p.name.padEnd(20) + ' error: ' + v.error;
|
||||
var why = blockReason(v, keep);
|
||||
return ' ' + p.name.padEnd(20) + ' supported=' + v.supported +
|
||||
' smooth=' + v.smooth + ' powerEfficient=' + v.powerEfficient +
|
||||
' [' + v.workload + ']' + (v.supported === false ? ' <-- BLOCKED' : '');
|
||||
' [' + v.workload + ']' +
|
||||
(why ? ' <-- BLOCKED (' + why + ')' : (keep.indexOf(p.key) >= 0 ? ' <-- pinned' : ''));
|
||||
}).join('\n');
|
||||
|
||||
return [
|
||||
@@ -505,7 +545,7 @@
|
||||
'MAX_TEXTURE_SIZE : ' + c.maxTextureSize,
|
||||
'HEVC canPlayType : ' + JSON.stringify(c.hevc),
|
||||
'canPlayType hook : ' + (c.cptMode || 'pending') +
|
||||
(c.cptMode === 'on' ? ' (downgraded: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
|
||||
(c.cptMode === 'on' ? ' (blocked: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
|
||||
'HEVC real (decodingInfo):',
|
||||
real
|
||||
].join('\n');
|
||||
|
||||
Reference in New Issue
Block a user