feat: count text subtitle cues and allow declaring the forced track #16
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/declare-forced-subtitle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #15 — based on
fix/no-subtitle-tracks-crash, so merge that first.The diff here is this change alone.
Two independent reasons the forced-narrative track of a streaming pull could not
be flagged at all.
1. Text subtitle tracks measured zero cues
Cue counting drops packets at or below
CLEAR_SEGMENT_MAX_BYTES(1000). Thatthreshold exists for exactly one reason — discarding PGS clear-screen segments —
but it applied to every codec. In a text track one small packet is one cue, so
the threshold discarded the entire track and every SubRip stream measured 0.
Known text codecs are now counted one packet per cue via a new
TEXT_SUB_CODECS. Anything unrecognised keeps the threshold and still reads 0,which the forced rule already refuses to act on — an unmeasured track should be
left alone, not guessed at.
On a real file the SubRip track goes from
0 cuesto2372 cues, against its1,235-cue DVB companion. The ~2× is the known teletext roll-up duplication, so
the number is plausible as well as non-zero.
2. The heuristic cannot work on a bilingual show
FORCED_MEDIAN_FRACTIONassumes a forced-narrative track is a small fraction ofa full one. True when a few lines of signage are translated; false whenever the
show is substantially in another language. Shōgun is around 70% Japanese, so its
forced track subtitles nearly every line and lands at roughly the full track's
count. Nothing sits below the median, so no forced track is found — silently,
looking exactly like a file that has none.
No measurement of the file recovers this, so
--forced-sub Ndeclares it(1-based, matching the printed
sNcolumn, repeatable). Supplying it bypassesthe heuristic for every track and prints that it did, because a bypassed
measurement that says nothing is how this repo produces confident wrong answers.
--default-sub-langstill picks exactly one forced track to carryflag-default.Counter-example recorded in the README per AGENTS.md.
Verification
ast.parseand the--helpgate pass acrosslib/*.py. Real media in~/Movies/Rips(DVB + SubRip, botheng):s1 1235 cues,s2 2372 cues(was0)--forced-sub 2flag-forced flag-default; bypass line printed--forced-sub 2 --default-sub-lang noneflag-forcedonly--forced-sub 1 --forced-sub 2flag-default--forced-sub 99--forced-sub 99: file has 2 subtitle track(s), exit 1--forced-sub 1on a 0-subtitle filefile has 0 subtitle track(s), exit 1--applyrun for real against a 2-minute clip. Before: both subtitle tracksforced=False default=False, unnamed. After: track 3forced=True default=True'English (forced)', track 2default=False'English SDH'.🤖 Generated with Claude Code