Zones fixes (#624)
* Fix formatting of zones help text * Fix issue where wrong number of frames are read in scenechange with zones active * Fix scenechange progress bar when zones active
This commit is contained in:
parent
ec9331283c
commit
3003f646c9
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -135,7 +135,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "av-scenechange"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/rust-av/av-scenechange?rev=0c63f493200eeccc21193d129fc63cb1265e40fa#0c63f493200eeccc21193d129fc63cb1265e40fa"
|
||||
source = "git+https://github.com/rust-av/av-scenechange?rev=a124199a746cba3ff2e08637836d37a91b6a9a58#a124199a746cba3ff2e08637836d37a91b6a9a58"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"rav1e",
|
||||
|
@ -792,6 +792,16 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "maybe-rayon"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0bd354d2614d2feeb08dd2afdb744a91ad3c886e2a04dac63e12fb32eb7f7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
|
@ -845,6 +855,12 @@ dependencies = [
|
|||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.1"
|
||||
|
@ -1157,7 +1173,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rav1e"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/xiph/rav1e#cbdf0703160bd4153975cb4ac3192476713f50c8"
|
||||
source = "git+https://github.com/xiph/rav1e#b5c76736440250409b173b07f99aa94e60ec47e2"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arg_enum_proc_macro",
|
||||
|
@ -1172,14 +1188,15 @@ dependencies = [
|
|||
"libc",
|
||||
"libfuzzer-sys",
|
||||
"log",
|
||||
"maybe-rayon",
|
||||
"nasm-rs",
|
||||
"new_debug_unreachable",
|
||||
"noop_proc_macro",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rayon",
|
||||
"regex",
|
||||
"rust_hawktracer",
|
||||
"rustc_version",
|
||||
|
@ -1674,9 +1691,10 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "v_frame"
|
||||
version = "0.2.5"
|
||||
source = "git+https://github.com/xiph/rav1e#cbdf0703160bd4153975cb4ac3192476713f50c8"
|
||||
source = "git+https://github.com/xiph/rav1e#b5c76736440250409b173b07f99aa94e60ec47e2"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"new_debug_unreachable",
|
||||
"noop_proc_macro",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
|
@ -1713,7 +1731,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
|||
[[package]]
|
||||
name = "vergen"
|
||||
version = "3.0.4"
|
||||
source = "git+https://github.com/xiph/rav1e#cbdf0703160bd4153975cb4ac3192476713f50c8"
|
||||
source = "git+https://github.com/xiph/rav1e#b5c76736440250409b173b07f99aa94e60ec47e2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"chrono",
|
||||
|
|
|
@ -47,5 +47,5 @@ debug-assertions = true
|
|||
overflow-checks = true
|
||||
|
||||
[patch.crates-io]
|
||||
av-scenechange = { git = "https://github.com/rust-av/av-scenechange", rev = "0c63f493200eeccc21193d129fc63cb1265e40fa" }
|
||||
av-scenechange = { git = "https://github.com/rust-av/av-scenechange", rev = "a124199a746cba3ff2e08637836d37a91b6a9a58" }
|
||||
console = { git = "https://github.com/console-rs/console", rev = "5484ea9d9f6884f6685349708e27bf08fab7703c" }
|
||||
|
|
|
@ -370,43 +370,55 @@ pub struct CliOpts {
|
|||
|
||||
/// Path to a file specifying zones within the video with differing encoder settings.
|
||||
///
|
||||
/// The zones file should include one zone per line, with each arg within a zone space-separated.
|
||||
/// No quotes or escaping are needed around the encoder args, as these are assumed to be the last argument.
|
||||
/// The zones file should include one zone per line,
|
||||
/// with each arg within a zone space-separated.
|
||||
/// No quotes or escaping are needed around the encoder args,
|
||||
/// as these are assumed to be the last argument.
|
||||
///
|
||||
/// The zone args on each line should be in this order:
|
||||
///
|
||||
/// ```
|
||||
/// start_frame end_frame encoder reset(opt) video_params
|
||||
/// ```
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```
|
||||
/// 136 169 aom --photon-noise 4 --cq-level=32
|
||||
/// 169 1330 rav1e reset -s 3 -q 42
|
||||
/// ```
|
||||
///
|
||||
/// Example line 1 will encode frames 136-168 using aomenc with the argument `--cq-level=32`
|
||||
/// and enable av1an's `--photon-noise` option.
|
||||
/// Note that the end frame number is *exclusive*. The start and end frame will both be forced
|
||||
/// to be scenecuts. Additional scene detection will still be applied within the zones.
|
||||
/// Example line 1 will encode frames 136-168 using aomenc
|
||||
/// with the argument `--cq-level=32` and enable av1an's `--photon-noise` option.
|
||||
/// Note that the end frame number is *exclusive*.
|
||||
/// The start and end frame will both be forced to be scenecuts.
|
||||
/// Additional scene detection will still be applied within the zones.
|
||||
/// `-1` can be used to refer to the last frame in the video.
|
||||
///
|
||||
/// The default behavior as shown on line 1 is to preserve any options passed to
|
||||
/// `--video-params` or `--photon-noise` in av1an, and append or overwrite
|
||||
/// the additional zone settings.
|
||||
/// The default behavior as shown on line 1 is to preserve
|
||||
/// any options passed to `--video-params` or `--photon-noise`
|
||||
/// in av1an, and append or overwrite the additional zone settings.
|
||||
///
|
||||
/// Example line 2 will encode frames 169-1329 using rav1e. The `reset` keyword instructs
|
||||
/// av1an to ignore any settings which affect the encoder, and use only the
|
||||
/// parameters from this zone.
|
||||
/// Example line 2 will encode frames 169-1329 using rav1e.
|
||||
/// The `reset` keyword instructs av1an to ignore any settings
|
||||
/// which affect the encoder, and use only the parameters from this zone.
|
||||
///
|
||||
/// For segments where no zone is specified, the settings passed to av1an itself will be used.
|
||||
/// For segments where no zone is specified,
|
||||
/// the settings passed to av1an itself will be used.
|
||||
///
|
||||
/// The video params which may be specified include any parameters that are allowed by
|
||||
/// the encoder, as well as the following av1an options:
|
||||
/// The video params which may be specified include any parameters
|
||||
/// that are allowed by the encoder, as well as the following av1an options:
|
||||
///
|
||||
/// - `-x`/`--extra-split`
|
||||
/// - `--min-scene-len`
|
||||
/// - `--passes`
|
||||
/// - `--photon-noise` (aomenc only)
|
||||
#[clap(long, parse(from_os_str), help_heading = "ENCODING")]
|
||||
#[clap(
|
||||
long,
|
||||
parse(from_os_str),
|
||||
help_heading = "ENCODING",
|
||||
verbatim_doc_comment
|
||||
)]
|
||||
pub zones: Option<PathBuf>,
|
||||
|
||||
/// Plot an SVG of the VMAF for the encode
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn av_scenechange_detect(
|
|||
if verbosity == Verbosity::Quiet {
|
||||
None
|
||||
} else {
|
||||
Some(&|frames, _keyframes| {
|
||||
Some(&|frames| {
|
||||
progress_bar::set_pos(frames as u64);
|
||||
})
|
||||
},
|
||||
|
@ -73,7 +73,7 @@ pub fn scene_detect(
|
|||
input: &Input,
|
||||
encoder: Encoder,
|
||||
total_frames: usize,
|
||||
callback: Option<&dyn Fn(usize, usize)>,
|
||||
callback: Option<&dyn Fn(usize)>,
|
||||
min_scene_len: usize,
|
||||
sc_pix_format: Option<Pixel>,
|
||||
sc_method: ScenecutMethod,
|
||||
|
@ -119,10 +119,25 @@ pub fn scene_detect(
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let callback = callback.map(|cb| {
|
||||
|frames, _keyframes| {
|
||||
cb(frames + frames_read);
|
||||
}
|
||||
});
|
||||
let sc_result = if bit_depth > 8 {
|
||||
detect_scene_changes::<_, u16>(&mut decoder, options, frame_limit, callback)
|
||||
detect_scene_changes::<_, u16>(
|
||||
&mut decoder,
|
||||
options,
|
||||
frame_limit,
|
||||
callback.as_ref().map(|cb| cb as &dyn Fn(usize, usize)),
|
||||
)
|
||||
} else {
|
||||
detect_scene_changes::<_, u8>(&mut decoder, options, frame_limit, callback)
|
||||
detect_scene_changes::<_, u8>(
|
||||
&mut decoder,
|
||||
options,
|
||||
frame_limit,
|
||||
callback.as_ref().map(|cb| cb as &dyn Fn(usize, usize)),
|
||||
)
|
||||
};
|
||||
if let Some(limit) = frame_limit {
|
||||
if limit != sc_result.frame_count {
|
||||
|
|
Loading…
Reference in a new issue