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
+29 -4
View File
@@ -1,6 +1,6 @@
use crate::audio_converter::convert_audio_to_aac;
use crate::dry_run::{print_shell_script_header, ShellScript};
use crate::file_finder::{find_audio_file, find_largest_video_file};
use crate::file_finder::{find_audio_file, find_ass_file, find_largest_video_file, get_output_name_from_ass};
use crate::video_merger::merge_video_and_audio;
use std::io::Result;
use std::path::Path;
@@ -34,13 +34,38 @@ pub fn merge_video_from_path(path: &Path, dry_run: bool, overwrite: bool) -> Res
crate::dry_run::print_shell_script(&script);
}
println!("Step 3: Looking for ASS subtitle file to determine output name...");
let output_name = match find_ass_file(path) {
Ok(ass_path) => {
println!("Found ASS file: {}", ass_path.display());
let name = get_output_name_from_ass(&ass_path);
println!("Output name will be: {}", name);
if dry_run {
let mut script = ShellScript::new();
script.add_variable("ASS_FILE", &ass_path);
script.add_variable_str("OUTPUT_NAME", &name);
crate::dry_run::print_shell_script(&script);
}
name
}
Err(_) => {
println!("No ASS file found, using video file name as output name");
let name = video_path.file_stem()
.and_then(|n| n.to_str())
.unwrap_or("output")
.to_string();
println!("Output name will be: {}", name);
name
}
};
println!();
println!("Step 3: Converting audio to AAC format...");
println!("Step 4: Converting audio to AAC format...");
let aac_path = convert_audio_to_aac(&audio_path, dry_run, overwrite)?;
println!();
println!("Step 4: Merging video and audio...");
let output_path = merge_video_and_audio(&video_path, &aac_path, dry_run, overwrite)?;
println!("Step 5: Merging video and audio...");
let output_path = merge_video_and_audio(&video_path, &aac_path, &output_name, path, dry_run, overwrite)?;
if dry_run {
println!();