Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pipeless scene detection for basic video inputs #847

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading