Skip to content

pianobin/srtAnki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

srtAnki

Generate Anki flashcards from an MP4 video and an SRT subtitles file.

  • Front of card — audio clip extracted from the video at the subtitle's timestamp (with optional screenshot)
  • Back of card — subtitle text

Requirements

  • Python 3.9+
  • ffmpeg installed and on your PATH

Installation

It's recommended to use a virtual environment to avoid conflicts with other Python packages.

# Create and activate a virtual environment
python -m venv .venv

# macOS / Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

To deactivate the virtual environment when you're done:

deactivate

Usage

GUI

python gui.py

A window will open with fields for all options. Select your video and subtitle files, adjust settings, and click Generate Cards.

CLI

python srt_anki.py <video> <subtitles> [options]

Arguments

Argument Description
video Path to the video file (MP4 or any ffmpeg-supported format)
subtitles Path to the SRT subtitles file

Options

Option Default Description
-o, --output output.apkg Output .apkg file path
-n, --deck-name srtAnki Deck Name for the Anki deck
-d, --delay SECONDS 0 Subtitle timing offset in seconds (see below)
-p, --padding SECONDS 0.35 Silence padding before/after each audio clip
--screenshot off Include a screenshot from the video on the front of each card
-m, --max-cards N unlimited Maximum number of cards to generate
--merge-gap SECONDS 1 Merge consecutive subtitle entries whose gap is ≤ this value

Subtitle delay

SRT files are often out of sync with the video. Use --delay to correct this:

  • If the audio plays before the subtitle appears (subtitles are late):

    python srt_anki.py movie.mp4 movie.srt --delay -1.5
  • If the audio plays after the subtitle appears (subtitles are early):

    python srt_anki.py movie.mp4 movie.srt --delay +1.5

The delay is added to every SRT timestamp when seeking in the video file. Positive values push the extraction window later; negative values push it earlier.

Examples

Basic usage:

python srt_anki.py movie.mp4 movie.srt

With screenshots, a custom deck name, and a sync correction:

python srt_anki.py movie.mp4 movie.srt \
  --screenshot \
  --deck-name "French Movie Vocab" \
  --delay -0.8 \
  --output french_movie.apkg

Merge subtitle entries that are less than 0.5 s apart (useful for dialogue split across lines):

python srt_anki.py movie.mp4 movie.srt --merge-gap 0.5

Importing into Anki

  1. Open Anki
  2. Go to File → Import
  3. Select the generated .apkg file

All audio clips (and screenshots if requested) are bundled inside the .apkg file — no separate files needed.

About

Python tool that generates Anki cards from a video and SRT file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages