From 3436cb0d5c346653fde6706ce72cee834e91c71d Mon Sep 17 00:00:00 2001 From: Alexander Jonathan Hardy Steffen Date: Sun, 23 Jun 2024 14:17:22 -0400 Subject: [PATCH] Update main.rs fixed ffmpeg bug --- src/main.rs | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3926e88..ae53a86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -198,24 +198,29 @@ fn combine_audio_files(input_file_path: &Path, output_dir: &Path) -> Result<()> }) .collect(); - let concat_file_path = output_dir.join("concat.txt"); - let mut concat_file = File::create(&concat_file_path)?; - for flac_file in &flac_files { - writeln!(concat_file, "file '{}'", flac_file.file_name().unwrap().to_str().unwrap())?; - } +let concat_file_path = output_dir.join("concat.txt"); +let mut concat_file = File::create(&concat_file_path)?; +for flac_file in &flac_files { + writeln!(concat_file, "file '{}'", flac_file.to_str().unwrap())?; +} + +let output_file_path = output_dir.join(format!("{}.flac", input_file_name)); +let status = Command::new("ffmpeg") + .args( + &[ + "-f", + "concat", + "-safe", + "0", + "-i", + concat_file_path.to_str().unwrap(), + "-c:a", + "flac", + output_file_path.to_str().unwrap(), + ] + ) + .status()?; - let output_file_path = output_dir.join(format!("{}.flac", input_file_name)); - let status = Command::new("ffmpeg") - .args( - &[ - "-i", - concat_file_path.to_str().unwrap(), - "-c:a", - "flac", - output_file_path.to_str().unwrap(), - ] - ) - .status()?; if !status.success() { anyhow::bail!("ffmpeg command failed"); @@ -234,4 +239,4 @@ fn remove_tmp(output_dir: &Path) -> Result<()> { } fs::remove_file(output_dir.join("concat.txt"))?; Ok(()) -} \ No newline at end of file +}