From 00b0d711d500e77208d31a1caa4c3bf0401b11fe Mon Sep 17 00:00:00 2001 From: liamb Date: Sat, 13 May 2023 11:22:26 +1000 Subject: [PATCH] watermark changes --- utils/.config.template.toml | 2 ++ video_creation/final_video.py | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/utils/.config.template.toml b/utils/.config.template.toml index b2fa1d4..c19cb06 100644 --- a/utils/.config.template.toml +++ b/utils/.config.template.toml @@ -36,6 +36,8 @@ resolution_h = { optional = false, default = 1920, example = 2560, explantation background_choice = { optional = true, default = "minecraft", example = "rocket-league", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", "minecraft-2","multiversus","fall-guys","steep", ""], explanation = "Sets the background for the video based on game name" } #background_audio = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Sets a audio to play in the background (put a background.mp3 file in the assets/backgrounds directory for it to be used.)" } #background_audio_volume = { optional = true, type = "float", default = 0.3, example = 0.1, explanation="Sets the volume of the background audio. only used if the background_audio is also set to true" } +background_watermark = { optional = false, type = "bool", default = true, example = false, options = [true, false,], explanation = "Hide or show a watermark." } +background_watermark_text = { optional = true, example = "Reddit Video Maker Bot", explanation = "Sets the watermark text for the video. Only displays if background_watermark is set to custom." } background_thumbnail = { optional = true, type = "bool", default = false, example = false, options = [true, false,], explanation = "Generate a thumbnail for the video (put a thumbnail.png file in the assets/backgrounds directory.)" } background_thumbnail_font_family = { optional = true, default = "arial", example = "arial", explanation = "Font family for the thumbnail text" } background_thumbnail_font_size = { optional = true, type = "int", default = 96, example = 96, explanation = "Font size in pixels for the thumbnail text" } diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 4838574..c3e5f14 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -2,7 +2,7 @@ import multiprocessing import os import re import shutil -from os.path import exists # Needs to be imported specifically +from os.path import exists # Needs to be imported specifically from typing import Final from typing import Tuple, Any @@ -299,17 +299,20 @@ def make_final_video( print_substep( f"Thumbnail - Building Thumbnail in assets/temp/{reddit_id}/thumbnail.png" ) - - text = f"Background by {background_config[2]}" - background_clip = ffmpeg.drawtext( - background_clip, - text=text, - x=f"(w-text_w)", - y=f"(h-text_h)", - fontsize=12, - fontcolor="White", - fontfile=os.path.join("fonts", "Roboto-Regular.ttf"), - ) + if settingsbackground["background_watermark"]: + if settingsbackground["background_watermark_text"]: + text = settingsbackground["background_watermark_text"] + else: + text = f"Background by {background_config[2]}" + background_clip = ffmpeg.drawtext( + background_clip, + text=text, + x=f"(w-text_w)", + y=f"(h-text_h)", + fontsize=12, + fontcolor="White", + fontfile=os.path.join("fonts", "Roboto-Regular.ttf"), + ) print_step("Rendering the video 🎥") from tqdm import tqdm