@@ 109,20 109,21 @@ fn phase_one(cli: &Cli, file: &DirEntry) -> (String, MkvInfo) {
mkv_info.file_name
);
- let merge_output = Command::new("mkvmerge")
- .args([
- "-o",
- &out_file,
- "--subtitle-tracks",
- // NOTE: Tracks are 0 indexed in mkvmerge.
- // So for things like subtitles, do a -1 for the numbers.
- &subtitles_to_keep
+ let mut args = vec!["-o".into(), out_file.clone()];
+ if !subtitles_to_keep.is_empty() {
+ args.push("--subtitle-tracks".into());
+ args.push(
+ subtitles_to_keep
.iter()
.map(|i| (i - 1).to_string())
.collect::<Vec<_>>()
.join(","),
- &file.path().to_string_lossy(),
- ])
+ );
+ }
+ args.push(file.path().to_string_lossy().into());
+
+ let merge_output = Command::new("mkvmerge")
+ .args(args)
.output()
.expect("failed to execute mkvmerge");