diff --git a/src/libs/args.rs b/src/libs/args.rs index 2d55163..2af06e6 100644 --- a/src/libs/args.rs +++ b/src/libs/args.rs @@ -74,6 +74,9 @@ pub enum Subcommands { }, Vid { + #[arg(short, long, default_value_t = String::from(""))] + input: String, + #[arg(long, default_value_t = false)] invert: bool, diff --git a/src/libs/vid_handler.rs b/src/libs/vid_handler.rs index ad00b41..a52982f 100644 --- a/src/libs/vid_handler.rs +++ b/src/libs/vid_handler.rs @@ -9,6 +9,7 @@ use ffmpeg_next::software::scaling::{context::Context, flag::Flags}; use ffmpeg_next::util::frame::video::Video; pub fn video( + input_path: String, invert: bool, colorful: bool, width: usize, @@ -21,12 +22,17 @@ pub fn video( ) { ffmpeg_next::init().unwrap(); - if let Ok(mut ictx) = input("bad_apple.webm") { + if input_path.is_empty() { + eprintln!("Error: No input path provided"); + std::process::exit(1); + } + + if let Ok(mut ictx) = input(&input_path) { let input = ictx .streams() .best(Type::Video) .ok_or(ffmpeg_next::Error::StreamNotFound) - .unwrap(); + .expect("Failed to find video stream"); let video_stream_index = input.index(); let context_decoder = diff --git a/src/main.rs b/src/main.rs index 0012e65..d393317 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,6 +42,7 @@ fn main() { ); } Some(libs::args::Subcommands::Vid { + input, invert, colorful, width, @@ -53,7 +54,7 @@ fn main() { lightmap, }) => { libs::vid_handler::video( - invert, colorful, width, height, pixel, noresize, matrix, nofill, lightmap, + input, invert, colorful, width, height, pixel, noresize, matrix, nofill, lightmap, ); } None => {