cli for src-lib to manual test inspect, clip
This commit is contained in:
29
src-lib/src/cli/main.rs
Normal file
29
src-lib/src/cli/main.rs
Normal 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);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user