Problems with std::process::Command


#1

Hi,
I’m trying to run ffmpeg via shell command to convert some audio files.
So when i run this code here:

println!("Converting ...");
            let mut arg1: String = "\"".to_owned();
            arg1.push_str(path.to_str().unwrap());
            arg1.push_str("\"");
            let mut arg2: String = "\"".to_owned();
            arg2.push_str(path.parent().unwrap().to_str().unwrap());
            arg2.push_str("/");
            arg2.push_str(path.file_stem().unwrap().to_str().unwrap());
            arg2.push_str(".mp3\"");

            println!("ffmpeg -i {:?} {:?}", arg1, arg2);
            let output = Command::new("ffmpeg")
                                 .args(&["-i", &arg1, &arg2])
                                 .output();

ffmpeg tells me that the path to the input file is invalid but when i copy the output of my debug println:
println!(“ffmpeg -i {:?} {:?}”, arg1, arg2);

and run it directly in my terminal everything works.

Am I missing something here?


#2

try it without quotes around the paths that should do the trick