scenes maybe???
parent
92b9765ad1
commit
ddfae7f86d
|
|
@ -111,7 +111,7 @@ fn _inspect(file: &String) -> Result<Inspection, String> {
|
|||
match std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-i", file,
|
||||
"-vf", "mpdecimate",
|
||||
"-vf", "mpdecimate,select='gt(scene,0.0)'",
|
||||
"-af", "silencedetect=n=-50dB:d=1",
|
||||
"-loglevel", "debug",
|
||||
"-f", "null",
|
||||
|
|
@ -152,10 +152,34 @@ impl Inspection {
|
|||
}
|
||||
|
||||
fn visual_spans(&self) -> Vec<ContentSpan> {
|
||||
self.spans_from_transitions(self.visual_transitions())
|
||||
let unstuck_spans = self.spans_from_transitions(self.visual_transitions_unstuck_frames());
|
||||
let scene_splits = self.visual_transitions_scene_splits();
|
||||
let mut result = vec![];
|
||||
for i in 0..unstuck_spans.len() {
|
||||
let mut span = unstuck_spans[i];
|
||||
for split in scene_splits.iter() {
|
||||
if &span.start < split && split < &span.stop { // TODO buffer
|
||||
result.push(ContentSpan{start: span.start, stop: *split});
|
||||
span.start = *split;
|
||||
}
|
||||
}
|
||||
result.push(span); // TODO assert nontrivial
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn visual_transitions(&self) -> Vec<f32> {
|
||||
fn visual_transitions_scene_splits(&self) -> Vec<f32> {
|
||||
self.lines.iter()
|
||||
.filter(|x| x.contains("[Parsed_select_1") && x.contains(" scene:"))
|
||||
.map(|x| f32::from_str(x
|
||||
.split(" scene:").nth(1).unwrap()
|
||||
.split(" ").nth(0).unwrap()
|
||||
).unwrap())
|
||||
.filter(|x| *x > 0.5) // TODO const
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn visual_transitions_unstuck_frames(&self) -> Vec<f32> {
|
||||
let lines: Vec<_> = self.lines.iter()
|
||||
.filter(|x| x.contains("Parsed_mpdecimate_0"))
|
||||
.filter(|x| x.contains("keep pts:") || x.contains("drop pts:"))
|
||||
|
|
@ -328,7 +352,10 @@ mod test_inspection {
|
|||
|
||||
assert_eq!(28.14, inspection.duration());
|
||||
|
||||
assert_eq!(4, inspection.visual_transitions().len());
|
||||
assert_eq!(1, inspection.visual_transitions_scene_splits().len()); // TODO
|
||||
assert_eq!(0.65986, inspection.visual_transitions_scene_splits()[0]); // TODO
|
||||
|
||||
assert_eq!(4, inspection.visual_transitions_unstuck_frames().len());
|
||||
assert_eq!(
|
||||
vec![ContentSpan{start: 1.0520501, stop: 22.0043}],
|
||||
inspection.visual_spans(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue