feat(subs): translate from an image-only release
A release whose only subtitle is a PGS or VobSub track was stuck both ways: the track satisfied English so no English SRT was ever fetched, and bitmaps can never feed a translator. §15 is amended to separate satisfying viewing from providing a translation source, and to carve a fetch made to obtain a source out of the no-upgrade rule. Timings come from the disc rather than from alass guessing at the audio. At import, each non-forced image track's packet timestamps are paired show-to-clear into a cue skeleton and stored; the fetched source is then aligned against that skeleton, and the translation made from it skips the post-translation pass, which could only move disc-exact timings off. Pairing is validated before it is trusted — even packet count, plausible durations, sane density for the runtime — because PGS allows several composition segments per subtitle and a slipped pairing is quietly half a second out. A track that fails validation gets no skeleton and falls back to aligning against the video, as does any file imported before this: there is no backfill. Closes #268 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
015b90a458
commit
6cd2902341
@@ -940,7 +940,9 @@ Replaces Bazarr. Phase 9 in §13; the `arr-subs` crate in §11.
|
||||
**Wanted set.** Global, not per root. Two languages are separately wanted for
|
||||
every media file: Portuguese — pt-PT preferred, pt-BR accepted — and English.
|
||||
A file is satisfied for a language when a subtitle in it exists, embedded or as
|
||||
a sidecar. This is deliberately unlike §5.2's audio rules, which attach to a
|
||||
a sidecar. Satisfying a language is a statement about *viewing* it, and not
|
||||
about having text in it — the distinction matters where an image track is all
|
||||
there is, and **Translation** below is where it bites. This is deliberately unlike §5.2's audio rules, which attach to a
|
||||
root: subtitles carry no blacklist there and none here. pt-BR subtitles are
|
||||
always fine.
|
||||
|
||||
@@ -952,6 +954,22 @@ they satisfy viewing but can never feed a translator, and arr does not OCR
|
||||
them. `arr-probe` already reports subtitle tracks with resolved languages; the
|
||||
format is the new fact it must carry.
|
||||
|
||||
**Cue skeletons.** What an image track *does* have is exact timings, because
|
||||
its packet timestamps are the disc's own cue structure. At import — while the
|
||||
file is being read and hardlinked anyway — arr derives a **cue skeleton** from
|
||||
each non-forced image track: `ffprobe -show_packets` on the track, packets
|
||||
paired show-to-clear, no pixel read. The skeleton has timings and no text, and
|
||||
that is enough, because `alass` matches on interval structure rather than on
|
||||
words. A sparse skeleton is still a strong reference; a downloaded subtitle and
|
||||
a retail disc's track never carry the same cues anyway.
|
||||
|
||||
The pairing is the whole of it, so it is validated before it is trusted: an
|
||||
even packet count, every implied duration plausible, and a cue density that
|
||||
fits the runtime. PGS permits several composition segments per subtitle, and a
|
||||
track built that way pairs into something that is quietly half a second out —
|
||||
worse than no skeleton. A track that fails validation gets none, and alignment
|
||||
falls back to the video.
|
||||
|
||||
**Providers.** OpenSubtitles.com, behind one trait.
|
||||
|
||||
**Ranking.** A `moviehash` match wins outright. Then an exact release-name
|
||||
@@ -975,6 +993,18 @@ a downloaded one, or one extracted from a text-format embedded track. Being
|
||||
able to translate from an embedded track is a deliberate improvement on
|
||||
Bazarr, which cannot.
|
||||
|
||||
**Fetching a source.** A release whose only subtitle is an image track has no
|
||||
text source and never will: the track satisfies its language, so nothing is
|
||||
ever fetched in it, and the track itself cannot be translated from. That is a
|
||||
deadlock, and it is broken by a narrow carve-out — when a wanted language needs
|
||||
translating and no text source exists, arr fetches a text subtitle in the image
|
||||
track's language *even though that language reads as satisfied*. The fetch
|
||||
obtains a source; it settles no want of its own, and the no-upgrade rule below
|
||||
does not apply to it. Where that track has a cue skeleton, the fetched subtitle
|
||||
is aligned against the skeleton rather than the video, which puts it on the
|
||||
disc's own timings instead of on a heuristic read of the audio. OCR remains a
|
||||
non-goal: this reaches the same place with real text.
|
||||
|
||||
**Translation backends.** Pluggable, each behind its own cargo feature: an
|
||||
OpenAI-compatible HTTP endpoint, DeepL, Google Translate, and a generic remote
|
||||
command driven by a configured template (`ssh box claude -p` is one instance
|
||||
@@ -988,6 +1018,11 @@ too — arr stops working on it. A real subtitle appearing later does not
|
||||
replace anything. Replacement is a manual action from the UI. This is §5.4's
|
||||
rule applied to subtitles.
|
||||
|
||||
The one exception is the source fetch above. It is not an upgrade: the language
|
||||
it downloads is already satisfied and stays satisfied by the same track it was
|
||||
before, and what the download settles is a *different* language's gap. Nothing
|
||||
is replaced, so nothing about the rule changes.
|
||||
|
||||
**On disk.** Sidecars live next to the video inside the §7.4 title folder,
|
||||
named `<video basename>.<lang>.srt`, e.g.
|
||||
`… - [2160p][WEB-DL][HDR10].pt-PT.srt`. A machine translation carries an extra
|
||||
@@ -1006,6 +1041,12 @@ reports no confidence value, so its output is accepted unless it is
|
||||
implausible — a shift beyond 60 seconds, or cues lost — in which case the
|
||||
unsynced original is kept and the file is flagged.
|
||||
|
||||
The reference is the video, except where a cue skeleton exists, and then it is
|
||||
the skeleton. A subtitle a skeleton accepted is already on disc-exact timings,
|
||||
and translation copies those timings over untouched, so the pass that would
|
||||
otherwise run on the translation is skipped: a second alignment has nothing
|
||||
left to find and can only move them off.
|
||||
|
||||
**Configuration.** Provider credentials and translator API keys are bootstrap
|
||||
config or environment, per §10 — a secret never becomes a database row. Wanted
|
||||
languages, chosen engine, per-provider enable and the daily budgets are
|
||||
|
||||
Reference in New Issue
Block a user