From 578dfc103386c2a141eb91c69da0c8cadc903a66 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 27 Nov 2024 18:41:20 +0200 Subject: [PATCH] fix: don't add --subtitle-tracks if no subtitles are kept --- src/main.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index e9f28a1..3c02293 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::>() .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"); -- 2.44.1