From a56ca42228b30f45877f3de9e97950a45a5fa130 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Mon, 22 Apr 2024 04:23:05 +0000 Subject: [PATCH] Fix vmaf flag check with target-quality Fixes issue where final vmaf was always ran if target-quality was set, this does not allow you to run vmaf without target-quality --- av1an-core/src/context.rs | 24 +++++++++++++----------- av1an-core/src/scenes.rs | 1 + av1an-core/src/settings.rs | 1 + av1an/src/main.rs | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/av1an-core/src/context.rs b/av1an-core/src/context.rs index 770ad6a3..85ffe58a 100644 --- a/av1an-core/src/context.rs +++ b/av1an-core/src/context.rs @@ -360,17 +360,19 @@ impl Av1anContext { temp_res = tq.vmaf_res.to_string(); } - if let Err(e) = vmaf::plot( - self.args.output_file.as_ref(), - &self.args.input, - tq.model.as_deref(), - temp_res.as_str(), - tq.vmaf_scaler.as_str(), - 1, - tq.vmaf_filter.as_deref(), - tq.vmaf_threads, - ) { - error!("VMAF calculation failed with error: {}", e); + if self.args.vmaf { + if let Err(e) = vmaf::plot( + self.args.output_file.as_ref(), + &self.args.input, + tq.model.as_deref(), + temp_res.as_str(), + tq.vmaf_scaler.as_str(), + 1, + tq.vmaf_filter.as_deref(), + tq.vmaf_threads, + ) { + error!("VMAF calculation failed with error: {}", e); + } } } diff --git a/av1an-core/src/scenes.rs b/av1an-core/src/scenes.rs index 6a554125..48c19520 100644 --- a/av1an-core/src/scenes.rs +++ b/av1an-core/src/scenes.rs @@ -291,6 +291,7 @@ fn get_test_args() -> Av1anContext { sc_downscale_height: None, force_keyframes: Vec::new(), target_quality: None, + vmaf: false, verbosity: Verbosity::Normal, workers: 1, set_thread_affinity: None, diff --git a/av1an-core/src/settings.rs b/av1an-core/src/settings.rs index 2a7d7727..9400409e 100644 --- a/av1an-core/src/settings.rs +++ b/av1an-core/src/settings.rs @@ -77,6 +77,7 @@ pub struct EncodeArgs { pub concat: ConcatMethod, pub target_quality: Option, + pub vmaf: bool, } impl EncodeArgs { diff --git a/av1an/src/main.rs b/av1an/src/main.rs index e649eef4..702d569c 100644 --- a/av1an/src/main.rs +++ b/av1an/src/main.rs @@ -742,6 +742,7 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result> { args.force_keyframes.as_deref().unwrap_or(""), )?, target_quality: args.target_quality_params(temp, video_params, output_pix_format.format), + vmaf: args.vmaf, verbosity: if args.quiet { Verbosity::Quiet } else if args.verbose {