feat: origin filename support.

This commit is contained in:
2026-01-04 03:12:57 +08:00
parent 5ce56bda36
commit ae0ba21b11
6 changed files with 97 additions and 19 deletions
+3 -3
View File
@@ -4,11 +4,11 @@ use std::io::Result;
use std::path::{Path, PathBuf};
use std::fs;
pub fn merge_video_and_audio(video_path: &Path, audio_path: &Path, dry_run: bool, overwrite: bool) -> Result<PathBuf> {
pub fn merge_video_and_audio(video_path: &Path, audio_path: &Path, output_name: &str, output_dir: &Path, dry_run: bool, overwrite: bool) -> Result<PathBuf> {
let origin_video_extension = video_path.extension().unwrap().to_str().unwrap();
let origin_filename = format!("original.{}", &origin_video_extension);
let origin_path = video_path.parent().unwrap().join(origin_filename);
let output_path = video_path.with_extension("mp4");
let output_path = output_dir.join(format!("{}.mp4", output_name));
if dry_run {
let mut script = ShellScript::new();
@@ -24,7 +24,7 @@ pub fn merge_video_and_audio(video_path: &Path, audio_path: &Path, dry_run: bool
.input_var("VIDEO_BACKUP")
.input_var("AUDIO_AAC")
.codec("copy")
.output_var("VIDEO_OUTPUT")
.output(&output_path)
.execute(true)?;
return Ok(output_path);
}