Submerger is a simple tool designed to merge subtitles from two different files into a single output file. It's especially useful for language learners who want to watch content with subtitles in multiple languages simultaneously.
The tool offers two main functionalities: Direct merging of two subtitle files for quick, one-time use, and a more advanced recursive search feature that scans entire directories for subtitle files matching specific language preferences.
- Merge two subtitle files into one output file.
- Customize subtitle color and position for the second subtitle track.
- Recursively search directories for subtitle files to merge based on language markers.
- Supports both
.srt
and.vtt
subtitle formats for inputs, only outputs.srt
however.
To install using cargo:
cargo install submerger
One way to build this project is using Rust.
Note: You must build using rust nightly!
Clone the repository:
git clone https://github.com/rasmus-kirk/submerger.git
cd submerger
Build the project:
cargo build --release
Note: Nix flakes must be enabled!
nix profile install github:rasmus-kirk/submerger
This project has a nix flake, so it can be built using nix:
nix build github:rasmus-kirk/submerger
If you just wish to run the program using nix:
nix run github:rasmus-kirk/submerger -- --help
To enter a developement shell with the correct rust-toolchain and rust analyzer using nix:
nix develop github:rasmus-kirk/submerger
If you use a shell other than bash:
nix develop github:rasmus-kirk/submerger -c $SHELL
You can either merge two files directly or recursively search a directory for matching subtitle pairs.
Merge two subtitle files into a single output:
submerger simple [OPTIONS] <SUB1> <SUB2> <OUT>
Required:
<SUB1>
: Path to the first subtitle file<SUB2>
: Path to the first subtitle file<OUT>
: Output file where the merged subtitles will be saved
Optional:
--color <COLOR>
Sets the color for the second subtitle track--position <POSITION>
Sets the position of the second subtitle track (default: top-center)--log-level <LOG_LEVEL>
Sets the level of logging [default: warn] [possible values: error, warn, info, debug, trace]--help
Print help
submerger simple movie.en.srt movie.ja.srt --out merged.srt --color "#fbf1c7" --position top-center
Search a directory for subtitle files matching given language codes and merge them:
submerger recursive [OPTIONS] <SUB1_LANG> <SUB2_LANG> <PATH>
Required:
<SUB1_LANG>
: Language code for the first subtitle file (e.g.,en
for English)<SUB2_LANG>
: Language code for the second subtitle file (e.g.,ja
for Japanese)<PATH>
: Root directory to recursively search for subtitle files
Optional:
--out-ext <OUT_EXT>
: The file extension for the output file (e.g.file.en.srt
->file.merged.srt
if set tomerged.srt
) (Default:srt
)--vtt
: Also match and convert VTT files. Note, this will not output VTT files, only SRT is supported as output (Default:true
)--color <COLOR>
: Sets the color for the second subtitle track--position <POSITION>
: Sets the position of the second subtitle track (Default:top-center
)--log-level <LOG_LEVEL>
: Sets the level of logging (Default:warn
)
- The program reads both subtitle files and assigns different positions and colors to the second subtitle track (if configured).
- When merging recursively, the program looks for matching subtitle files
based on the provided language codes (e.g.,
en
,ja
). - If hearing-impaired subtitles are found (e.g.,
en.hi
), they will be preferred only if normal subtitles (en
) aren't available. - The merged subtitle output file will contain both sets of subtitles and
be written as
ORIGINAL_FILE_NAME.OUT_EXTENSION$
in the directory where the matching subs were found.
submerger recursive en ja ./movies --color "#fbf1c7" --position top-center
This project is licensed under the MIT License. See the LICENSE file for details.