Merge pull request #1574 from liamb13/background_audio
adds background audio
This commit is contained in:
2 files changed
+31
-2
No files matched your search
@@ -34,8 +34,8 @@ resolution_h = { optional = false, default = 1920, example = 2560, explantation
|
||||
|
||||
[settings.background]
|
||||
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_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_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" }
|
||||
|
||||
@@ -177,6 +177,35 @@ def make_final_video(
|
||||
|
||||
screenshot_width = int((W * 45) // 100)
|
||||
audio = ffmpeg.input(f"assets/temp/{reddit_id}/audio.mp3")
|
||||
# adds background audio
|
||||
if settings.config["settings"]["background"]["background_audio"]:
|
||||
if not exists("assets/backgrounds/background.mp3"):
|
||||
print_substep(
|
||||
"No audio file found called background.mp3 in assets/backgrounds", "red"
|
||||
)
|
||||
else:
|
||||
if (
|
||||
not settings.config["settings"]["background"]["background_audio_volume"]
|
||||
or settings.config["settings"]["background"]["background_audio_volume"] == 0
|
||||
or settings.config["settings"]["background"]["background_audio_volume"] == ""
|
||||
):
|
||||
print_substep(
|
||||
"Background audio volume is set to 0, not adding background audio",
|
||||
"red",
|
||||
)
|
||||
else:
|
||||
# sets volume to config
|
||||
bg_audio = (
|
||||
ffmpeg.input("assets/backgrounds/background.mp3")
|
||||
.filter(
|
||||
"volume",
|
||||
settings.config["settings"]["background"]["background_audio_volume"],
|
||||
)
|
||||
)
|
||||
# merges audio and bg_audio
|
||||
merged_audio = ffmpeg.filter([audio, bg_audio], "amix", duration="longest")
|
||||
# sets final audio to merged audio
|
||||
audio = merged_audio
|
||||
|
||||
image_clips = list()
|
||||
|
||||
|
||||
Reference in new issue
Block a user