Hello,
This Bash script automatically remuxes .mkv files using FFmpeg, ensuring that only selected subtitle languages are kept and properly sorted.
It is designed to process both movies and TV series from separate input folders and generate clean, organized output files.
Additional features:
They are automatically detected based on the filename language code.
This Bash script automatically remuxes .mkv files using FFmpeg, ensuring that only selected subtitle languages are kept and properly sorted.
It is designed to process both movies and TV series from separate input folders and generate clean, organized output files.
What the Script Does
Input Directories
- Movies
- TV Series (with season subfolders)
Processing
Remuxes MKV files without re-encoding:- Video → copy
- Audio → copy
- Subtitles → copy
Additional features:
- Keeps only allowed subtitle languages
- Requires at least one predefined regional subtitle language (Bosnian / Croatian / Serbian)
- Ignores PGS subtitles
- Automatically detects and includes external .srt subtitle files
- Sorts subtitles alphabetically (A → Z)
- Adds proper subtitle metadata (language + title)
- Skips already processed files unless new subtitles are detected
- Uses a lock mechanism to prevent multiple simultaneous executions
- Automatically removes stale lock files
- Logs everything (success, failed, missing subtitles)
- Retries failed remux attempts up to 3 times
- Optional Telegram notification support
External Subtitles (.srt)
External .srt files must be placed in the same directory as the input .mkv file.They are automatically detected based on the filename language code.





