| dvd2h265.sh | ||
| list_audio.sh | ||
| list_runtimes.sh | ||
| movie_rename.sh | ||
| README.md | ||
| resize_1080p_hvec.sh | ||
| set_default_audiotrack.sh | ||
| simple_movie_rename.sh | ||
| srtsyncfix.sh | ||
srtsyncfix.sh
srtsyncfix.sh is a small Bash utility that automatically synchronizes .srt subtitle files with their corresponding .mkv video files using ffsubsync. It scans a directory (or a single MKV file), finds matching SRTs, fixes their timing, and prevents repeated processing by adding a marker line to already‑synced subtitles.
The script is designed for media libraries where filenames may contain spaces, parentheses, brackets, or other special characters.
Features
- Automatically finds
.mkvfiles in a directory - Matches
.srtfiles based on the MKV basename - Uses ffsubsync to correct subtitle timing
- Adds a marker line to avoid reprocessing already‑synced subtitles
- Safely handles filenames with spaces, brackets, parentheses, and unicode
- Removes macOS AppleDouble junk files (
._*) - Optional language filtering (e.g.,
eng,nld,pob)
Requirements
1. ffsubsync
This is the core subtitle‑sync engine.
Install via pip:
pip install ffsubsync
Or, if using Python 3 explicitly:
pip3 install ffsubsync
2. Python 3
Required by ffsubsync.
Check:
python3 --version
3. Bash
The script uses Bash arrays, process substitution, and set -euo pipefail.
4. Standard Unix tools
These are available on all Linux distributions:
findmvgrepdirnamebasenameprintfmapfile
No additional packages required.
Usage
Process the current directory
./srtsyncfix.sh .
Process a specific movie file
./srtsyncfix.sh "FERRARI (2023) - [1080p].mkv"
Process only a specific subtitle language
./srtsyncfix.sh . nld
This will only sync subtitles ending in .nld.srt.
How it works
- Removes AppleDouble files (
._*) - Optionally strips leading/trailing quotes from filenames
- Detects MKV files
- For each MKV:
- Finds matching SRT files
- Skips SRTs already containing the marker line
- Runs ffsubsync to generate a corrected subtitle
- Backs up the original SRT
- Replaces it with the fixed version
- Appends a marker line:
Fixed by ffs on YYYY-MM-DD HH:MM
Backup behavior
Every processed subtitle is backed up automatically:
original.srt → original.srt.bck
This ensures you can always revert if needed.
Notes
- The script does not modify MKV files.
- The script only processes
.srtsubtitles. - The skip‑marker prevents expensive reprocessing.
- Filenames with quotes can be cleaned automatically if desired.
If you want, I can also generate:
- a man‑page style README
- a GitHub‑ready README with badges
- a usage example section with real MKV/SRT filenames
Just tell me what style you prefer.