impl ffmpeg.screenshot too
This commit is contained in:
@@ -16,6 +16,22 @@ fn clip(output: &String, input: &String, start: f32, stop: f32) -> Result<(), St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn screenshot(output: &String, input: &String, ts: f32) -> Result<(), String> {
|
||||||
|
match std::process::Command::new("ffmpeg")
|
||||||
|
.args([
|
||||||
|
"-y",
|
||||||
|
"-ss", &ts.to_string(),
|
||||||
|
"-i", input,
|
||||||
|
"-frames:v", "1",
|
||||||
|
"-q:v", "2",
|
||||||
|
output,
|
||||||
|
])
|
||||||
|
.output() {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(msg) => Err(format!("failed to ffmpeg screenshot {}: {}", input, msg)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn inspect(file: &String) -> Result<Inspection, String> {
|
fn inspect(file: &String) -> Result<Inspection, String> {
|
||||||
match std::process::Command::new("ffmpeg")
|
match std::process::Command::new("ffmpeg")
|
||||||
.args([
|
.args([
|
||||||
@@ -178,6 +194,21 @@ mod test_inspection {
|
|||||||
use super::*;
|
use super::*;
|
||||||
const FILE: &str = "/Users/breel/Movies/bel_1_1.mp4";
|
const FILE: &str = "/Users/breel/Movies/bel_1_1.mp4";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_screenshot() {
|
||||||
|
let output = format!("{}.clipped.jpg", FILE);
|
||||||
|
screenshot(
|
||||||
|
&output,
|
||||||
|
&FILE.to_string(),
|
||||||
|
3.0,
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
let inspection = inspect(&output);
|
||||||
|
assert_eq!(true, inspection.is_ok());
|
||||||
|
let inspection = inspection.unwrap();
|
||||||
|
assert_eq!(0.04, inspection.duration());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clip() {
|
fn test_clip() {
|
||||||
let output = format!("{}.clipped.mp4", FILE);
|
let output = format!("{}.clipped.mp4", FILE);
|
||||||
|
|||||||
Reference in New Issue
Block a user