Skip to content

Commit c18ed0e

Browse files
committed
Implement pipeless scene detection for basic video inputs
1 parent a506a92 commit c18ed0e

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

Cargo.lock

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

av1an-core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ crossbeam-channel = "0.5.1"
4040
crossbeam-utils = "0.8.5"
4141
textwrap = "0.16.0"
4242
path_abs = "0.5.1"
43-
av-scenechange = { version = "0.11.0", default-features = false, features = [
43+
av-scenechange = { version = "0.12.0", default-features = false, features = [
44+
"ffmpeg",
4445
"vapoursynth",
4546
] }
4647
y4m = "0.8.0"

av1an-core/src/scene_detect.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::thread;
55
use ansi_term::Style;
66
use anyhow::bail;
77
use av_scenechange::decoder::Decoder;
8+
use av_scenechange::ffmpeg::FfmpegDecoder;
89
use av_scenechange::vapoursynth::VapoursynthDecoder;
910
use av_scenechange::{detect_scene_changes, DetectionOptions, SceneDetectionSpeed};
1011
use ffmpeg::format::Pixel;
@@ -263,19 +264,23 @@ fn build_decoder(
263264
let input_pix_format = crate::ffmpeg::get_pixel_format(path.as_ref())
264265
.unwrap_or_else(|e| panic!("FFmpeg failed to get pixel format for input video: {e:?}"));
265266
bit_depth = encoder.get_format_bit_depth(sc_pix_format.unwrap_or(input_pix_format))?;
266-
Decoder::Y4m(y4m::Decoder::new(
267-
Command::new("ffmpeg")
268-
.args(["-r", "1", "-i"])
269-
.arg(path)
270-
.args(filters.as_ref())
271-
.args(["-f", "yuv4mpegpipe", "-strict", "-1", "-"])
272-
.stdin(Stdio::null())
273-
.stdout(Stdio::piped())
274-
.stderr(Stdio::null())
275-
.spawn()?
276-
.stdout
277-
.unwrap(),
278-
)?)
267+
if !filters.is_empty() {
268+
Decoder::Y4m(y4m::Decoder::new(
269+
Command::new("ffmpeg")
270+
.args(["-r", "1", "-i"])
271+
.arg(path)
272+
.args(filters.as_ref())
273+
.args(["-f", "yuv4mpegpipe", "-strict", "-1", "-"])
274+
.stdin(Stdio::null())
275+
.stdout(Stdio::piped())
276+
.stderr(Stdio::null())
277+
.spawn()?
278+
.stdout
279+
.unwrap(),
280+
)?)
281+
} else {
282+
Decoder::Ffmpeg(FfmpegDecoder::new(path)?)
283+
}
279284
}
280285
};
281286

0 commit comments

Comments
 (0)