seconv: VobSub OCR + --time-codes-only for image-based subtitles#11629
Merged
Conversation
Add a --time-codes-only flag to seconv that extracts time codes from image-based subtitles into a text format without OCR: each entry keeps its timing with empty text and no OCR engine is created, so it works without Tesseract/Paddle/etc. installed. Verified that SE re-opens the resulting empty-text SRT/ASSA files (timing preserved). Wire VobSub into the text/OCR pipeline (previously "use the UI"): - .sub + .idx pairs (text target) - VobSub-in-MKV (S_VOBSUB) - VobSub-in-MP4 (handler subp) Both full OCR and --time-codes-only are supported for all of these, reusing the existing VobSub bitmap decoder. Fix .sub routing: a binary VobSub .sub with no .idx companion is now detected (MPEG pack header) and read directly (stream PTS timing + default palette, with a note) instead of falling through to the MicroDVD text loader; a genuine text MicroDVD .sub still routes to the text loader. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the request in #10068: a way to produce a timing-only output file from image-based subtitles without a full OCR.
--time-codes-onlyExtracts time codes from image-based sources into any text format, skipping OCR entirely — each entry keeps its timing with empty text, and no OCR engine is created, so it works without Tesseract/Paddle/nOCR/etc. installed.
The empty-text output re-opens cleanly in Subtitle Edit itself (verified against the actual
SubRipandAdvancedSubStationAlphaparsers — both detect the format and reload all cues with timing intact). A few stricter third-party players may drop empty cues; switching the placeholder to e.g.-would be a one-line change if that's ever wanted.VobSub wired into the text/OCR pipeline
VobSub previously errored with "use the Subtitle Edit UI for now". It's now supported in seconv for both full OCR and
--time-codes-only, reusing the existing VobSub bitmap decoder:.sub+.idxpairs (text target)S_VOBSUB)subp).subrouting fixA binary VobSub
.subwith no.idxcompanion is now detected via its MPEG pack header (00 00 01 BA) and read directly —VobSubParser.OpenSubIdxalready falls back to the stream's own PTS timing with a default palette — emitting a note rather than failing or being misparsed as MicroDVD. A genuine text MicroDVD.substill routes to the text loader. (Without the.idx, colors use a default palette so OCR accuracy may be slightly lower; timing is accurate and--time-codes-onlyis unaffected.)Tests
TimeCodesOnlyTest—.sup→ SRT with timing and no recognised text, no OCR engine needed.ContainerLoaderTest— replaced the old (CI-skipped) "OCRs PGS and skips VobSub" test with a deterministic--time-codes-onlytest proving both the PGS and VobSub tracks incontainer_image.mkvnow convert.VobSubRoutingTest— binary-vs-text.subdetection, and a MicroDVD.sub(no.idx) still converting as text.163 tests pass, 0 skipped.
Note (out of scope here)
While testing I found a pre-existing latent bug: with
--overwrite, two same-language tracks in one container resolve to the same output filename and the second silently clobbers the first (the track-number disambiguation only runs when!Overwrite). It affects text tracks too and is now easier to hit since VobSub tracks are no longer skipped. Happy to fix in a follow-up — the clean fix is to track output paths written within a single run and disambiguate even under--overwrite.🤖 Generated with Claude Code