feat: count text subtitle cues and allow declaring the forced track (re-target of #16) #17
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?
Re-targets the commit from #16 at
main. No code change from #16 — thecontent is byte-identical, as
git diff origin/fix/no-subtitle-tracks-crash origin/feat/declare-forced-subtitleconfirms (empty).#16 was opened with its base set to
fix/no-subtitle-tracks-crashto keep itsdiff reviewable while #15 was still open. That was a mistake: #15 merged that
branch into
mainbefore #16 merged into it, so #16's merge landed on a branchthat
mainhad already taken, and the feature commit was never inmain. Allthree PRs report
merged=True, which is how it went unnoticed.main..origin/feat/declare-forced-subtitleis a single commit and merges cleanly.Two independent reasons the forced-narrative track of a streaming pull could not
be flagged.
1. Text subtitle tracks measured zero cues
Cue counting drops packets at or below
CLEAR_SEGMENT_MAX_BYTES(1000), athreshold that exists for exactly one reason — discarding PGS clear-screen
segments — but which applied to every codec. In a text track one small packet
is one cue, so it discarded the whole 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 cuesagainst its1,235-cue DVB companion. The ~2x is the known teletext roll-up duplication, so
the figure 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