Skip to content

Add Extract Embedded Subtitles plugin#734

Merged
DogmaDragon merged 2 commits into
stashapp:mainfrom
loco306:plugin/extract-embedded-subtitles
Jun 28, 2026
Merged

Add Extract Embedded Subtitles plugin#734
DogmaDragon merged 2 commits into
stashapp:mainfrom
loco306:plugin/extract-embedded-subtitles

Conversation

@loco306

@loco306 loco306 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Extract Embedded Subtitles

A new external plugin that extracts embedded text subtitle tracks from video files into external .srt sidecar files, named so Stash's existing caption matcher attaches them automatically.

Addresses the long-standing request in stashapp/stash#3875. video.js can't render embedded tracks directly, so the practical path is generating sidecar .srt files - this automates that.

What it does

  • ffprobe enumerates each scene file's subtitle streams.
  • Each text track (SubRip / ASS / SSA / mov_text / WebVTT / .) is extracted via ffmpeg -map 0:<idx> -c:s srt to <video>.<lang>.srt, matching GetCaptionPath in pkg/file/video/caption.go (ISO-639 language segment, or no segment when the language is unknown).
  • Touched folders are rescanned (metadata_scan) so captions appear without a full library rescan.
  • Provides the Extract Embedded Subtitles task (whole library), an optional Scene.Create.Post hook (off by default), and Overwrite / Extract On Scan settings.

Limitations (documented in the README)

  • Image-based subtitles (PGS / VobSub / DVB) are skipped - they're bitmaps and need OCR.
  • ASS/SSA styling is lost when converting to SRT (predictable; the source file is never modified).
  • One caption per language, since Stash stores one caption per language/type; the default track wins ties.

Testing

  • Manifest validated against validator/plugin.schema.json (Draft-07) - passes.
  • Extraction verified end-to-end against real ffmpeg/ffprobe on a multi-track MKV: English (SubRip), Spanish (muxed as ASS to exercise ASS?SRT), and an untagged track ? produced name.eng.srt, name.spa.srt, name.srt with text and timing intact; re-run is idempotent (skips existing).
  • Filename / ISO-639 logic unit-tested against the rules in caption.go.
  • Not yet exercised inside a running Stash server; caption attachment relies on Stash's existing external-subtitle support plus metadata_scan.

Disclosure

Per the repo's LLM-assisted contributions policy: this was LLM-assisted, human-reviewed, and tested (details above). The code is original - it shells out to ffmpeg/ffprobe and uses stashapp-tools like other plugins here - and I take responsibility for it.

Relates to: stashapp/stash#3875

Extracts embedded text subtitle tracks from video files into external
.srt sidecar files that Stash recognises as captions (stashapp/stash#3875).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@DogmaDragon DogmaDragon added the type:plugin Plugins label Jun 28, 2026
@DogmaDragon DogmaDragon merged commit d900e9a into stashapp:main Jun 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants