src-lib/video.rs pub is naisu
parent
2928595812
commit
90569967c7
|
|
@ -1,4 +1,4 @@
|
|||
mod ffmpeg;
|
||||
pub mod video;
|
||||
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::str::FromStr;
|
||||
use core::cmp::Ordering;
|
||||
|
||||
fn clip(output: &String, input: &String, start: f32, stop: f32) -> Result<(), String> {
|
||||
pub fn clip(output: &String, input: &String, content_span: ContentSpan) -> Result<(), String> {
|
||||
match std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y",
|
||||
"-ss", &start.to_string(),
|
||||
"-ss", &content_span.start.to_string(),
|
||||
"-i", input,
|
||||
"-t", &(stop - start).to_string(),
|
||||
"-t", &(content_span.stop - content_span.start).to_string(),
|
||||
output,
|
||||
])
|
||||
.output() {
|
||||
|
|
@ -16,7 +16,7 @@ fn clip(output: &String, input: &String, start: f32, stop: f32) -> Result<(), St
|
|||
}
|
||||
}
|
||||
|
||||
fn screenshot(output: &String, input: &String, ts: f32) -> Result<(), String> {
|
||||
pub fn screenshot(output: &String, input: &String, ts: f32) -> Result<(), String> {
|
||||
match std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y",
|
||||
|
|
@ -32,7 +32,14 @@ fn screenshot(output: &String, input: &String, ts: f32) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn inspect(file: &String) -> Result<Inspection, String> {
|
||||
pub fn inspect(file: &String) -> Result<Vec<ContentSpan>, String> {
|
||||
match _inspect(file) {
|
||||
Ok(inspection) => Ok(inspection.content_spans()),
|
||||
Err(msg) => Err(msg)
|
||||
}
|
||||
}
|
||||
|
||||
fn _inspect(file: &String) -> Result<Inspection, String> {
|
||||
match std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-i", file,
|
||||
|
|
@ -60,7 +67,7 @@ struct Inspection {
|
|||
}
|
||||
|
||||
impl Inspection {
|
||||
pub fn content_spans(&self) -> Vec<ContentSpan> {
|
||||
fn content_spans(&self) -> Vec<ContentSpan> {
|
||||
self.overlap_spans(
|
||||
&self.visual_spans(),
|
||||
&self.audible_spans(),
|
||||
|
|
@ -203,7 +210,7 @@ mod test_inspection {
|
|||
3.0,
|
||||
).unwrap();
|
||||
|
||||
let inspection = inspect(&output);
|
||||
let inspection = _inspect(&output);
|
||||
assert_eq!(true, inspection.is_ok());
|
||||
let inspection = inspection.unwrap();
|
||||
assert_eq!(0.04, inspection.duration());
|
||||
|
|
@ -215,11 +222,10 @@ mod test_inspection {
|
|||
clip(
|
||||
&output,
|
||||
&FILE.to_string(),
|
||||
3.0,
|
||||
5.0,
|
||||
ContentSpan{start: 3.0, stop: 5.0},
|
||||
).unwrap();
|
||||
|
||||
let inspection = inspect(&output);
|
||||
let inspection = _inspect(&output);
|
||||
assert_eq!(true, inspection.is_ok());
|
||||
let inspection = inspection.unwrap();
|
||||
assert_eq!(2.0, inspection.duration());
|
||||
|
|
@ -227,7 +233,7 @@ mod test_inspection {
|
|||
|
||||
#[test]
|
||||
fn test_inspect() {
|
||||
let inspection = inspect(&FILE.to_string());
|
||||
let inspection = _inspect(&FILE.to_string());
|
||||
assert_eq!(true, inspection.is_ok());
|
||||
let inspection = inspection.unwrap();
|
||||
|
||||
|
|
@ -261,8 +267,8 @@ mod test_inspection {
|
|||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, PartialOrd)]
|
||||
pub struct ContentSpan {
|
||||
start: f32,
|
||||
stop: f32,
|
||||
pub start: f32,
|
||||
pub stop: f32,
|
||||
}
|
||||
|
||||
impl ContentSpan {
|
||||
Loading…
Reference in New Issue