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
- Python 3.9+
- ffmpeg installed and on your
PATH
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.txtTo deactivate the virtual environment when you're done:
deactivatepython gui.pyA window will open with fields for all options. Select your video and subtitle files, adjust settings, and click Generate Cards.
python srt_anki.py <video> <subtitles> [options]
| Argument | Description |
|---|---|
video |
Path to the video file (MP4 or any ffmpeg-supported format) |
subtitles |
Path to the SRT subtitles file |
| 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 |
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.
Basic usage:
python srt_anki.py movie.mp4 movie.srtWith 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.apkgMerge 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- Open Anki
- Go to File → Import
- Select the generated
.apkgfile
All audio clips (and screenshots if requested) are bundled inside the .apkg file — no separate files needed.