mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
watermark scaling
This commit is contained in:
1 parent
d07d9f77cb
commit
d07365daf1
3 files changed
+13
-8
No files matched your search
+3
-2
@@ -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<JobSuccess
|
||||
|
||||
let command_exit_status = model_dependencies
|
||||
.ffmpeg_watermark_command
|
||||
.execute_inference(ffmpeg_logo_watermark_command::InferenceArgs {
|
||||
.execute_inference(WatermarkArgs {
|
||||
video_path: &output_video_fs_path,
|
||||
maybe_override_logo_path: None,
|
||||
alpha: 0.6,
|
||||
scale: 0.1, // NB: 0.1 is good for the Storyteller logo @ 2653x512 placed on 1024x576 output.
|
||||
output_path: &output_video_fs_path_watermark,
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ use crate::job::job_loop::process_single_job_error::ProcessSingleJobError;
|
||||
use crate::job::job_types::workflow::comfy_ui::comfy_ui_inference_command::InferenceArgs;
|
||||
use crate::job::job_types::workflow::comfy_ui::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;
|
||||
|
||||
fn get_file_extension(mimetype: &str) -> Result<&'static str> {
|
||||
let ext = match mimetype {
|
||||
@@ -436,10 +436,11 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
|
||||
let command_exit_status = model_dependencies
|
||||
.ffmpeg_watermark_command
|
||||
.execute_inference(ffmpeg_logo_watermark_command::InferenceArgs {
|
||||
.execute_inference(WatermarkArgs {
|
||||
video_path: &comfy_output_video_file,
|
||||
maybe_override_logo_path: None,
|
||||
alpha: 0.6,
|
||||
scale: 0.1, // NB: 0.1 is good for the Storyteller logo @ 2653x512 placed on 1024x576 output.
|
||||
output_path: &output_video_fs_path_watermark,
|
||||
});
|
||||
|
||||
|
||||
+7
-4
@@ -47,7 +47,7 @@ pub enum ExecutableOrCommand {
|
||||
Command(String),
|
||||
}
|
||||
|
||||
pub struct InferenceArgs<P: AsRef<Path>> {
|
||||
pub struct WatermarkArgs<P: AsRef<Path>> {
|
||||
/// -i: video path
|
||||
pub video_path: P,
|
||||
|
||||
@@ -57,6 +57,9 @@ pub struct InferenceArgs<P: AsRef<Path>> {
|
||||
/// 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<P: AsRef<Path>>(
|
||||
&self,
|
||||
args: InferenceArgs<P>,
|
||||
args: WatermarkArgs<P>,
|
||||
) -> CommandExitStatus {
|
||||
match self.do_execute_inference(args) {
|
||||
Ok(exit_status) => exit_status,
|
||||
@@ -117,7 +120,7 @@ impl FfmpegLogoWatermarkCommand {
|
||||
|
||||
fn do_execute_inference<P: AsRef<Path>>(
|
||||
&self,
|
||||
args: InferenceArgs<P>,
|
||||
args: WatermarkArgs<P>,
|
||||
) -> AnyhowResult<CommandExitStatus> {
|
||||
|
||||
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(" ");
|
||||
|
||||
|
||||
Reference in new issue
Block a user