hud-9: render native (SRT) subtitles in the HUD; stop persisting the layout override
ADDENDUM 10. Two more independent subtitle problems found on device.
1. Normal (non-ASS) subtitles never reached the HUD. Jellyfin's
htmlVideoPlayer-plugin only routes ssa/ass through SubtitlesOctopus
(`if (!['ssa','ass'].includes(codec))` -> pgssub/vobsub/custom-element/native);
subrip falls through to the browser's own TextTrack rendering, so there is no
libass canvas at all (measured with the CN SRT selected: 0 libass canvases,
0 .videoSubtitles overlays, textTracks[0] = manualTrack/mode=showing/315 cues).
No layout setting could have made that work.
updateSource() now picks the source every XR frame: the libass canvas when it
exists, otherwise the active TextTrack cue (fallback: the .videoSubtitlesInner
overlay). The native text is cleaned, wrapped and painted white-on-black into a
private 1920x1080 canvas that flows through the unchanged crop/upload/HUD path.
prepare() is skipped when there is no libass canvas. New diagnostics:
stats.subSource / stats.subNativeText, Subtitles.getSourceKind().
2. ADDENDUM 9 persisted state.subLayout, and a stale 'mono' in jfvr.settings.v1
silently forced the mono branch on the default dual-eye content (dual:false,
eyeW:4320, crop across the seam -> both eyes side by side). The override is now
per-session: not saved, not restored, 'auto' at boot.
Verified on device with hud-9:
CN_dual_eye (ass) -> subSource=libass, dual=true, eyeW=2160,
crop=[1040,768,1176,924], copyND=0.055
CN (subrip) -> subSource=native, dual=false, eyeW=1920, text="进去了呢",
crop 256x88, uploads climbing
The private cue canvas was read back and OCR'd (cue "怎么样?好好地" -> "怎么样? 好好地"),
and injecting/removing a fake libass canvas flips subSource with no errors.
This commit is contained in:
+61
-2
@@ -1,9 +1,10 @@
|
||||
# Jellyfin Web VR180 — 项目交接文档
|
||||
|
||||
> 给新对话用。读完这份就能接手,不需要重新调查环境。
|
||||
> 最后更新:已部署版本 `b9c3a5`(`NS.version = hud-8`;ADDENDUM 6 字幕深度/大小解耦
|
||||
> 最后更新:已部署版本 `e394bcb`(`NS.version = hud-9`;ADDENDUM 6 字幕深度/大小解耦
|
||||
> + 7 唤出门限/前面板精简 + 7b 锁按钮与「锁定」面板模式 + 8/8b 画面搬迁(实时拖动)
|
||||
> + 9 rAF 代理修复(VR 内字幕不再冻结)+ 普通/双目字幕自动识别)
|
||||
> + 9 rAF 代理修复(VR 内字幕不再冻结)+ 普通/双目字幕自动识别
|
||||
> + 10 原生(SRT 等)字幕由插件自绘到 HUD;布局覆盖不再持久化)
|
||||
>
|
||||
> ⚠️ **Jellyfin web 注册了 service worker**(`serviceworker.js`,scope `/web/`),会把
|
||||
> `index.html` 缓存在 SW cache 里。重新部署后如果只是普通刷新,浏览器可能仍用旧的
|
||||
@@ -414,6 +415,7 @@ handsReady / handsErr / handsSources / handsFrames
|
||||
subMode / subCanvasSize / subCrop / subTex / subOpacity / subPlacement
|
||||
subLockAngle / subAngleDeg / subTextDeg / subYOverZ ← ADDENDUM 6
|
||||
subLayout / subDual / subEyeW / subCopyND / subCenterInk ← ADDENDUM 9
|
||||
subSource / subNativeText ← ADDENDUM 10
|
||||
ctlSubsOn / ctlSubDist / ctlSubAngle / ctlSubLock ← 控制条实际画出的值
|
||||
ctlLock / ctlMode / ctlHold / pressAt / lastActivate ← ADDENDUM 7/7b 锁、面板保持与唤出判定
|
||||
videoYaw / videoPitch / videoRotMode / videoTransformWritable ← ADDENDUM 8/8b 画面搬迁
|
||||
@@ -569,3 +571,60 @@ for (const k of await caches.keys()) await caches.delete(k);
|
||||
- 下次戴上头显后要确认:`stats.subLayout=auto`、双目轨 `subDual=true/subEyeW=2160/
|
||||
subCrop` 落在左半屏(≤2160)、普通轨 `subDual=false/subEyeW=4320/subCrop` 跨中线、
|
||||
`subCopyND` 与 `subCenterInk` 是否符合上面的表。
|
||||
|
||||
---
|
||||
|
||||
## 14. ADDENDUM 10 — 普通字幕(SRT 等)为什么读不到(已部署 `e394bcb` / `hud-9`)
|
||||
|
||||
### 14.1 根因:Jellyfin 只把 ssa/ass 交给 libass
|
||||
|
||||
`htmlVideoPlayer-plugin` 的 `renderTracksEvents` 决策:
|
||||
|
||||
```js
|
||||
a = (n.Codec || '').toLowerCase();
|
||||
if (!X.includes(a)) { // X = ['ssa','ass']
|
||||
if (a === 'pgssub') -> renderPgs
|
||||
if (Y.includes(a)) -> renderVobSub // Y = ['dvdsub','vobsub']
|
||||
if (!u(h.fe)) -> renderSubtitlesWithCustomElement // DOM 覆盖层
|
||||
/* 否则落到原生 TextTrack 分支 */
|
||||
}
|
||||
return renderSsaAss(...); // 只有 ssa/ass
|
||||
```
|
||||
|
||||
所以 `subrip`/`vtt` **根本不会创建 libass canvas**。设备实测(选中 `CN` SRT 时):
|
||||
`canvas.libassjs-canvas` 数量 **0**、`.libassjs-canvas-parent` 0、`.videoSubtitles` 0,
|
||||
只有 `video.textTracks[0] = { kind:'subtitles', label:'manualTrack', mode:'showing',
|
||||
cues:315 }` —— 浏览器用 `::cue` 自己画。插件**无论改什么布局都读不到任何东西**。
|
||||
|
||||
### 14.2 修复(`src/10-subtitles.js`)
|
||||
|
||||
`updateSource()` 每帧挑来源:
|
||||
|
||||
- 有非空 `canvas.libassjs-canvas` → `srcKind='libass'`(原路径不变);
|
||||
- 否则若有 showing 的 TextTrack 或 `.videoSubtitlesInner` → `srcKind='native'`:
|
||||
从 `textTracks[i].activeCues` 读当前 cue(兜底读 DOM 覆盖层 `innerText`),
|
||||
清洗 ASS/HTML 标签与双向控制符、按字符折行,用白字黑描边画进私有 1920×1080
|
||||
canvas,再走**完全相同的裁剪/上传/HUD 管线**;
|
||||
- 都没有 → `srcKind='none'`,清一次字幕条。
|
||||
|
||||
`prepare()` 在没有 libass canvas 时跳过(放大播放器框只是为了让 libass 重渲染,原生
|
||||
canvas 是我们自己的)。新增诊断 `stats.subSource` / `stats.subNativeText` 和
|
||||
`Subtitles.getSourceKind()`。
|
||||
|
||||
### 14.3 血的教训:布局覆盖**不要持久化**
|
||||
|
||||
ADDENDUM 9 把 `state.subLayout` 存进了 `jfvr.settings.v1`。结果一个残留的 `'mono'`
|
||||
静默地把默认的**双目**内容强制成普通:`dual:false`、`eyeW:4320`、裁剪跨越两眼接缝 →
|
||||
HUD 把两只眼的字幕并排显示。找这个 bug 花的时间比写检测还多。现在 `subLayout`
|
||||
**不持久化**(和 `subtitles`、`subMode:'off'` 同理),开机恒为 `auto`,面板可临时改。
|
||||
|
||||
### 14.4 设备实测(`hud-9`)
|
||||
|
||||
| 选中轨 | `subSource` | 结果 |
|
||||
|---|---|---|
|
||||
| `CN_dual_eye`(ass,idx 0) | `libass` | `dual:true`、`eyeW:2160`、`crop:[1040,768,1176,924]`(左半)、`copyND:0.055`、uploads 递增 |
|
||||
| `CN`(subrip,idx 1) | `native` | `dual:false`、`eyeW:1920`、canvas 1920×1080、`text:"进去了呢"`、`crop` 256×88、uploads 递增 |
|
||||
|
||||
私有 cue canvas 还读回做了 OCR(cue `怎么样?好好地` → OCR `怎么样? 好好地`);
|
||||
注入/移除一个假的 `canvas.libassjs-canvas` 能让 `subSource` 在 `libass`/`native`
|
||||
间切换且 `subErr` 为空。
|
||||
|
||||
Reference in New Issue
Block a user