Files
2026-01-04 01:46:39 +08:00

53 lines
1.8 KiB
Rust

mod audio_converter;
mod dry_run;
mod ffmpeg;
mod file_finder;
mod merge;
mod video_merger;
use clap::Parser;
use std::io::Result;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "bilibili-merge")]
#[command(about = "Merge bilibili downloaded videos with audio")]
#[command(long_about = "Merge bilibili downloaded videos with audio.
This tool automatically:
1. Finds the largest video file in the specified directory (by file size)
2. Looks for the corresponding audio file (.m4a) with the same base name
3. Converts the audio to AAC format
4. Merges the video and audio into a single file
The original video file will be renamed to 'original.<extension>' as a backup.
The merged file will be saved as '<original_name>.mp4' regardless of the input format.")]
struct Args {
/// Path to the directory containing video and audio files
///
/// The tool will automatically select the largest file (by size) in this directory
/// as the video file to merge. Make sure only one video file exists, or the largest
/// one will be selected.
#[arg(default_value = ".")]
path: PathBuf,
/// Dry run mode: show what would be done without actually doing it
///
/// In dry-run mode, the tool will output a shell script showing all operations
/// that would be performed. You can copy and execute this script manually if needed.
#[arg(short = 'n', long = "dry-run")]
dry_run: bool,
/// Force overwrite existing files
///
/// By default, the tool will not overwrite existing files. Use this flag to
/// force overwrite if the output file already exists.
#[arg(short = 'f', long = "force")]
force: bool,
}
fn main() -> Result<()> {
let args = Args::parse();
merge::merge_video_from_path(&args.path, args.dry_run, args.force)
}