Skip to main content

Generate SRT/VTT subtitles from video files using faster-whisper

Project description

            _     _ _
  ___ _   _| |__ | (_)_ __   ___
 / __| | | | '_ \| | | '_ \ / _ \
 \__ \ |_| | |_) | | | | | |  __/
 |___/\__,_|_.__/|_|_|_| |_|\___|

  video in -> subtitles out

subline

Dead-simple subtitle generation for video files. Point it at a file (or a folder full of them) and get .srt or .vtt subtitles -- powered by faster-whisper.

subline movie.mp4          # auto-detect language, writes movie.srt
  .-------------------.
  |  movie.mp4        |
  '-------------------'
          |
          v
  +-----------------+       +-----------------+
  |  ffmpeg extract |  -->  | faster-whisper  |
  |  audio track    |       | transcribe      |
  +-----------------+       +-----------------+
                                    |
                                    v
                            .-------------------.
                            |  movie.srt        |
                            |                   |
                            |  1                |
                            |  00:00:01,000 --> |
                            |  00:00:03,500     |
                            |  Hello world.     |
                            '-------------------'

Features

  • Auto language detection -- or pin a language with --language es
  • Batch mode -- pass multiple files or a whole directory
  • SRT & VTT output formats
  • CUDA auto-detect -- uses NVIDIA GPU when available, CPU otherwise
  • Multi-track aware -- picks the first audio track and tells you about the rest
  • Skip existing -- resume interrupted batch runs with --skip-existing

Quick start

brew install ffmpeg                   # or: apt install ffmpeg
pipx install subline
subline movie.mp4

Requirements

  • Python 3.10+
  • ffmpeg and ffprobe on your PATH
    # macOS
    brew install ffmpeg
    # Ubuntu / Debian
    sudo apt install ffmpeg
    # Windows (scoop)
    scoop install ffmpeg
    

Install

# With pipx (recommended -- installs in its own environment)
pipx install subline

# Or with pip
pip install subline

Trouble installing on Python 3.14? Some dependencies (av) may not support 3.14 yet. Use an older interpreter:

brew install python@3.13
pipx install subline --python python3.13

Usage

subline [options] <path...>
Flag Default Description
--language CODE auto-detect ISO 639-1 language code (es, en, fr, ...)
--model NAME turbo Whisper model: tiny, base, small, medium, turbo
--audio-track N auto (first track) Stream index of the audio track to use
--format srt|vtt srt Output subtitle format
--output-dir DIR next to source Where to write subtitle files
--device DEVICE auto Force cuda or cpu
--skip-existing off Don't re-transcribe if subtitle already exists

Examples

# Single file, auto-detect language
subline interview.mp4

# Spanish audio, specific model
subline --language es --model medium lecture.mp4

# Whole directory, skip already-done files
subline --skip-existing ~/Videos/series/

# Multiple files, VTT output in a separate folder
subline --format vtt --output-dir ./subs ep01.mp4 ep02.mp4 ep03.mp4

# Force second audio track (0-indexed stream id from ffprobe)
subline --audio-track 2 foreign_film.mkv

Output

Found 3 file(s) | model=turbo | language=auto-detect | device=cpu

Loading model 'turbo' on cpu...

[1/3] ep01.mp4
  Using audio track 1 (spa)
  Extracting audio (track 1)...
  Transcribing 45 min of audio...
  Detected language: es (98%)
  [ 52.3%] 350 segments, 124s elapsed, ETA 1m53s
  Done: 671 segments in 3m58s -> ep01.srt

[2/3] ep02.mp4
  ...

Development

git clone https://github.com/fenelon/subline.git
cd subline
pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subline-0.1.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subline-0.1.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file subline-0.1.2.tar.gz.

File metadata

  • Download URL: subline-0.1.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for subline-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64f38a92c77943cfc74c9506c47263922a140df3f38eba4efc73412ed04b821d
MD5 d86207b63aa7d8578298e1c0f721b1d8
BLAKE2b-256 ad26d8f684ea3ea45190c07f6d8a9368f34d05bbfd3ceb4435f67e09ca191efe

See more details on using hashes here.

File details

Details for the file subline-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: subline-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for subline-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a92f10c09a4845458d318c2d27db3749bce20403d3b11efdd46c175bcd7f804d
MD5 a8ab50ac768e435cbcccba7328110173
BLAKE2b-256 a8d1abfed670c2622e77fd220975103c7f8eef40be0fa848d5ccb3726301cbd5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page