Skip to content

Commit

Permalink
Implement pipeless scene detection for basic video inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed May 23, 2024
1 parent f259c44 commit 756370c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion av1an-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ crossbeam-channel = "0.5.1"
crossbeam-utils = "0.8.5"
textwrap = "0.16.0"
path_abs = "0.5.1"
av-scenechange = { version = "0.11.0", default-features = false, features = [
av-scenechange = { version = "0.12.0", default-features = false, features = [
"ffmpeg",
"vapoursynth",
] }
y4m = "0.8.0"
Expand Down
31 changes: 18 additions & 13 deletions av1an-core/src/scene_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::thread;
use ansi_term::Style;
use anyhow::bail;
use av_scenechange::decoder::Decoder;
use av_scenechange::ffmpeg::FfmpegDecoder;
use av_scenechange::vapoursynth::VapoursynthDecoder;
use av_scenechange::{detect_scene_changes, DetectionOptions, SceneDetectionSpeed};
use ffmpeg::format::Pixel;
Expand Down Expand Up @@ -263,19 +264,23 @@ fn build_decoder(
let input_pix_format = crate::ffmpeg::get_pixel_format(path.as_ref())
.unwrap_or_else(|e| panic!("FFmpeg failed to get pixel format for input video: {e:?}"));
bit_depth = encoder.get_format_bit_depth(sc_pix_format.unwrap_or(input_pix_format))?;
Decoder::Y4m(y4m::Decoder::new(
Command::new("ffmpeg")
.args(["-r", "1", "-i"])
.arg(path)
.args(filters.as_ref())
.args(["-f", "yuv4mpegpipe", "-strict", "-1", "-"])
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.spawn()?
.stdout
.unwrap(),
)?)
if !filters.is_empty() {
Decoder::Y4m(y4m::Decoder::new(
Command::new("ffmpeg")
.args(["-r", "1", "-i"])
.arg(path)
.args(filters.as_ref())
.args(["-f", "yuv4mpegpipe", "-strict", "-1", "-"])
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.spawn()?
.stdout
.unwrap(),
)?)
} else {
Decoder::Ffmpeg(FfmpegDecoder::new(path)?)
}
}
};

Expand Down

0 comments on commit 756370c

Please sign in to comment.