From d07365daf1e0c5c05c4846341be4ddfdecd6ff28 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 14 Apr 2024 20:39:18 -0400 Subject: [PATCH] watermark scaling --- .../job/job_types/lipsync/sad_talker/process_job.rs | 5 +++-- .../job/job_types/workflow/comfy_ui/process_job.rs | 5 +++-- .../common_commands/ffmpeg_logo_watermark_command.rs | 11 +++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/service/job/inference_job/src/job/job_types/lipsync/sad_talker/process_job.rs b/crates/service/job/inference_job/src/job/job_types/lipsync/sad_talker/process_job.rs index 0bf3e7ba27..bdeb98fb36 100644 --- a/crates/service/job/inference_job/src/job/job_types/lipsync/sad_talker/process_job.rs +++ b/crates/service/job/inference_job/src/job/job_types/lipsync/sad_talker/process_job.rs @@ -27,7 +27,7 @@ use crate::job::job_types::lipsync::sad_talker::resize_image::resize_image; use crate::job::job_types::lipsync::sad_talker::sad_talker_inference_command::InferenceArgs; use crate::job::job_types::lipsync::sad_talker::validate_job::validate_job; use crate::job_dependencies::JobDependencies; -use crate::util::common_commands::ffmpeg_logo_watermark_command; +use crate::util::common_commands::ffmpeg_logo_watermark_command::WatermarkArgs; /// The maximum that either width or height can be const MAX_DIMENSION : u32 = 1500; @@ -254,10 +254,11 @@ pub async fn process_job(args: SadTalkerProcessJobArgs<'_>) -> Result Result<&'static str> { let ext = match mimetype { @@ -436,10 +436,11 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result> { +pub struct WatermarkArgs> { /// -i: video path pub video_path: P, @@ -57,6 +57,9 @@ pub struct InferenceArgs> { /// transparency pub alpha: f32, + /// scale + pub scale: f32, + /// --output_audio_filename: output path of wav file. pub output_path: P, } @@ -107,7 +110,7 @@ impl FfmpegLogoWatermarkCommand { pub fn execute_inference>( &self, - args: InferenceArgs

, + args: WatermarkArgs

, ) -> CommandExitStatus { match self.do_execute_inference(args) { Ok(exit_status) => exit_status, @@ -117,7 +120,7 @@ impl FfmpegLogoWatermarkCommand { fn do_execute_inference>( &self, - args: InferenceArgs

, + args: WatermarkArgs

, ) -> AnyhowResult { let mut command = String::new(); @@ -150,7 +153,7 @@ impl FfmpegLogoWatermarkCommand { // ffmpeg filter command.push_str(" -filter_complex "); command.push_str(&format!("\"[1]format=rgba,colorchannelmixer=aa={}[logo];", args.alpha)); - command.push_str("[logo][0]scale2ref=oh*mdar:ih*0.2[logo][video];"); + command.push_str(&format!("[logo][0]scale2ref=oh*mdar:ih*{}[logo][video];", args.scale)); command.push_str("[video][logo]overlay=(main_w-overlay_w)-10:(main_h-overlay_h)-10\""); command.push_str(" ");