Skip to content

fix: keep SRT text after blank lines, convert sidecar subtitles to UTF-8 and notify failures once - #13

Merged
InfinityPacer merged 4 commits into
mainfrom
fix/0.0.6-subtitles
Oct 22, 2026
Merged

InfinityPacer merged 4 commits into
mainfrom
fix/0.0.6-subtitles

Conversation

@InfinityPacer

@InfinityPacer InfinityPacer commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

问题

0.0.5 之后发现三处问题。

  • 外挂 SRT 某句台词中间有空行时,空行之后的文字丢失。
  • 外挂字幕请求不带编码,按 UTF-8 解码,GBK、Big5 等文件在 Plex 直连或反代没能识别时显示成乱码。
  • 播放中途出错时,Plex 的错误对话框与画面里的中断提示同时出现。

结果

  • SRT 里没有时间行的块接在上一句后面,时间行无效的句子连同后续块一起丢弃,WebVTT 仍以空行结束一句。
  • 外挂字幕请求带 encoding=utf-8,由 Plex 识别并转换编码。Plex 也转不了时(替换字符不少于 4 个且占非 ASCII 字符一半以上)提示编码暂不支持,视频照常播放。
  • 起播后出错时,Hook 确认 Plex 的播放器收到了错误事件就只显示 Plex 的对话框,收不到时回报 takeover-error-unsurfaced,由宿主显示中断提示,不会静默卡住。
  • 注释写明 H.264 丢弃前导画面可能带来短暂花屏,行为不变。

验证

  • 本地 Node 22、pnpm 11,pnpm build、pnpm typecheck、pnpm lint、pnpm test(422 passed)、git diff --check 均通过。
  • 真实页面验收,用这一版构建的扩展在 Chrome 156 里经外网打开 Cirvel 实例的 Plex Web(4.160.0),播放一部 STRM 电影(MKV、H.264 1080p、EAC3 5.1、内嵌 SRT)。由 ShimWeave 接管(MSE),从续播点起播后画面持续推进,Seek 到 30 分钟后继续播放,ShimWeave 的字幕轨道已加载。

🤖 Generated with Claude Code

InfinityPacer and others added 4 commits October 21, 2026 10:59
The sidecar parser split files on blank lines and treated each block as a
cue, so an SRT cue whose text contained an empty line lost everything
after it. In SRT a block without a timing line now continues the previous
cue, and a block after a cue with an invalid timing line is dropped with
it. WebVTT keeps ending a cue at a blank line, so NOTE, STYLE and REGION
blocks between cues are still skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since the hook started handing read-class takeover failures to Plex as a
Shaka network error, a read failure after ready showed both the s1002
dialog and the in-video interruption notice. Decode and format failures
after ready, which the hook hands to Plex as a media error, did the same.

The host no longer shows the interruption notice on its own after ready.
The hook knows whether Plex's player actually received an error event
and replies with takeover-error-unsurfaced when it did not, because the
failure code has no Plex error surface, the Shaka error factory is
missing, or dispatching threw. Only then does the host show its notice,
so playback never stalls silently. Nothing is reported when Plex has
already started another load or for the media_detached stop code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sidecar subtitles were requested without an encoding and decoded as
UTF-8, which relied on a reverse proxy in front of Plex converting them.
GBK or Big5 files it could not identify, or any non-UTF-8 file served by
Plex directly, showed as mojibake.

The request now carries encoding=utf-8. Plex Media Server then detects
the file encoding itself and converts it to UTF-8, and a proxy that
forwards the query keeps working because it receives valid UTF-8.

When Plex cannot convert either, the file is reported as an unsupported
encoding instead of drawn as mojibake. The text counts as undecodable
when it holds at least 4 replacement characters and they make up at
least half of its non-ASCII characters. GBK and Big5 decoded as UTF-8
turn over 90% of their non-ASCII characters into replacement characters,
so a mostly English file with a few garbled CJK words is still caught,
while a stray bad byte in a small or a mostly valid UTF-8 file is not.
The architecture document describes the new request and fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The leading-picture filter claimed the codec guarantees that pictures
after the random access point never reference the dropped leading
pictures. That holds for HEVC CRA, whose trailing pictures may not
reference RASL or RADL pictures, but H.264 recovery-point I frames carry
no such constraint, so a later picture can reference a dropped leading
reference picture and decode with brief artifacts until the next random
access point. The comment now says so and why the same rule still
applies: kept leading pictures are undecodable at the start key and
rejected by the muxer mid-stream. Behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@InfinityPacer
InfinityPacer merged commit c7bde18 into main Oct 22, 2026
1 check passed
@InfinityPacer
InfinityPacer deleted the fix/0.0.6-subtitles branch October 22, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant