feat: argparse and dry-run.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use crate::ffmpeg::FFmpegCommand;
|
||||
use std::io::Result;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn convert_audio_to_aac(audio_path: &Path, dry_run: bool, overwrite: bool) -> Result<PathBuf> {
|
||||
let aac_path = audio_path.with_extension("aac");
|
||||
|
||||
if dry_run {
|
||||
let mut script = crate::dry_run::ShellScript::new();
|
||||
script.add_comment("Convert audio to AAC format");
|
||||
script.add_variable("AUDIO_AAC", &aac_path);
|
||||
crate::dry_run::print_shell_script(&script);
|
||||
} else {
|
||||
println!("Converting audio: {} -> {}", audio_path.display(), aac_path.display());
|
||||
}
|
||||
|
||||
if dry_run {
|
||||
FFmpegCommand::new()
|
||||
.overwrite(overwrite)
|
||||
.input_var("AUDIO_FILE")
|
||||
.codec("copy")
|
||||
.output_var("AUDIO_AAC")
|
||||
.execute(true)?;
|
||||
} else {
|
||||
FFmpegCommand::new()
|
||||
.overwrite(overwrite)
|
||||
.input(audio_path)
|
||||
.codec("copy")
|
||||
.output(&aac_path)
|
||||
.execute(false)?;
|
||||
println!("Audio conversion completed: {}", aac_path.display());
|
||||
}
|
||||
|
||||
Ok(aac_path)
|
||||
}
|
||||
Reference in New Issue
Block a user