DEVELOPMENT ENVIRONMENT

~liljamo/entamin

578dfc103386c2a141eb91c69da0c8cadc903a66 — Jonni Liljamo 6 days ago 264d94e
fix: don't add --subtitle-tracks if no subtitles are kept
1 files changed, 11 insertions(+), 10 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +11 -10
@@ 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");