cli for src-lib to manual test inspect, clip

This commit is contained in:
Bel LaPointe
2023-12-28 09:39:27 -05:00
parent 1e7c82294f
commit 47339a01f9
3 changed files with 37 additions and 375 deletions

29
src-lib/src/cli/main.rs Normal file
View File

@@ -0,0 +1,29 @@
use lib;
use std::str::FromStr;
fn main() {
let cmd = std::env::args().nth(1).expect("first argument must be [inspect] or [clip]");
let file = std::env::args().nth(2).expect("second argument must be [path to file]");
match cmd.as_ref() {
"clip" => {
let content_span = lib::video::ContentSpan{
start: f32::from_str(&std::env::args().nth(3).expect("third argument must be [start time as f32 seconds]")).unwrap(),
stop: f32::from_str(&std::env::args().nth(4).expect("fourth argument must be [stop time as f32 seconds]")).unwrap(),
};
let output = format!("{}.clipped.mp4", &file);
eprintln!("clipping {} from {} to {} as {}...", &file, &content_span.start, &content_span.stop, &output);
lib::video::clip(&output, &file, content_span).unwrap();
},
"inspect" => {
eprintln!("inspecting {}...", &file);
let content_spans = lib::video::inspect(&file).unwrap();
content_spans.iter()
.for_each(|x| {
println!("{}..{}", x.start, x.stop);
});
},
_ => {
panic!("unrecognized command {}", cmd);
},
};
}