Skip to content
rgroenewoudtPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

AutoSub

AutoSub is a command-line tool that creates English .srt subtitles for your video files. It uses Whisper speech recognition (through Whisper.net) and runs on the GPU with Vulkan.

Point it at a folder, and it will:

  • Find all video files in the folder and its subfolders.
  • Skip videos that already have subtitles (a separate subtitle file, or an embedded text subtitle track).
  • Extract the English audio track with FFmpeg.
  • Transcribe the audio with Whisper and write {videoname}.en.srt next to the video.

Features

  • Recursive scan of a directory, with support for many video formats (.mkv, .mp4, .avi, .m2ts, .mov and more).
  • Smart skipping: videos with existing subtitles are not processed again. Videos with only image-based subtitles (PGS, VobSub) are still transcribed, because these subtitles are not text.
  • Remembers earlier runs in a small SQLite database (data.db), so a second run is fast. Failed files are retried on the next run.
  • Picks the right audio track: the first English track that is not a commentary track.
  • Language check: the audio must be detected as English, otherwise no subtitle is created and an error is logged.
  • Readable subtitles: long sentences are split into at most two lines, at punctuation or at a word boundary.
  • Tidies up Subs/ folders: subtitle files from a Subs/ folder (used by some releases) are moved next to the video.
  • Live progress in the terminal.
  • list command to see which videos have no subtitles at all.

Requirements

  • .NET 10 SDK
  • FFmpeg (ffmpeg and ffprobe must be on your PATH)
  • A GPU with Vulkan support is recommended. Without it, Whisper runs on the CPU, which is much slower.
  • Windows (x64) or Linux (x64)

Getting started

git clone https://github.com/rgroenewoudt/AutoSub.git
cd AutoSub
dotnet build

Usage

Generate subtitles

dotnet run --project AutoSub -- <directory> [--model <model>]

Example:

dotnet run --project AutoSub -- "D:\Movies" --model medium
Option Description Default
<directory> The folder with video files to process (required)
-m, --model Whisper model: tiny, base, small, medium, large-v1, large-v2, large-v3 small

The model is downloaded on first use and saved as ggml-{model}.bin in the current folder. Bigger models give better results but are slower and need more memory.

List videos without subtitles

dotnet run --project AutoSub -- list <directory>

This command does not change anything. It prints the paths of all videos without subtitles to stdout and a summary to stderr, so you can save the list to a file:

dotnet run --project AutoSub -- list "D:\Movies" > missing.txt

Note: the list command counts all embedded subtitles, also image-based ones (PGS, VobSub), as subtitles.

Files created at runtime

These files are created in the current working folder:

File Purpose
ggml-{model}.bin The downloaded Whisper model
data.db SQLite database with videos that are already processed or skipped
log.txt Log file (NLog)

To process all files again, delete data.db.

Development

dotnet build
dotnet test                                          # run all tests
dotnet test --filter "LongSentence_SplitsOnPeriod"   # run one test

Tests use NUnit. The tests in ManualTests.cs are marked [Explicit] and need real video files on your computer.

Database migrations use EF Core:

dotnet ef migrations add <Name> --project AutoSub
dotnet ef database update --project AutoSub

Built with

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages