rendering video and audio

pull/1590/head
Lucas 2 years ago
parent 405b1f89eb
commit 5a103e76cd

@ -34,8 +34,8 @@ resolution_h = { optional = false, default = 1920, example = 2560, explantation
[settings.background]
background_video = { 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 = ["minecraft","lofi"], 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.1, example = 0.05, explanation="Sets the volume of the background audio. Warning: if you set more than 1.0, the volume will be increased" }
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" }

@ -4,5 +4,15 @@
"https://www.youtube.com/watch?v=2p3nBYUaJz8",
"minecraft.mp3",
"adriPixs"
],
"lofi":[
"https://www.youtube.com/watch?v=BEXL80LS0-I",
"lofi.mp3",
"stompsPlaylist"
],
"undertale":[
"https://www.youtube.com/watch?v=TIokr8jJPkM",
"undertale.mp3",
"abby"
]
}

@ -115,20 +115,12 @@ def chop_background(
video_choice = f"{background_config['video'][2]}-{background_config['video'][1]}"
audio_choice = f"{background_config['audio'][2]}-{background_config['audio'][1]}"
id = re.sub(r"[^\w\s-]", "", reddit_object["thread_id"])
# audioclip = audioclip.fx( volumex, 0.2)
# final_audio = mpe.CompositeAudioClip([final.audio, audioclip])
# # lowered_audio = audio_background.multiply_volume( # todo get this to work
# # VOLUME_MULTIPLIER) # lower volume by background_audio_volume, use with fx
# final.set_audio(final_audio)
background_video = VideoFileClip(f"assets/backgrounds/video/{video_choice}")
background_audio = AudioFileClip(f"assets/backgrounds/audio/{audio_choice}")
start_time_video, end_time_video = get_start_and_end_times(video_length, background_video.duration)
start_time_audio, end_time_audio = get_start_and_end_times(video_length, background_audio.duration)
#background_audio.set_start(start_time_audio)
#background_audio.set_end(end_time_audio)
background_audio = background_audio.fx(afx.volumex,0.1)
#background_audio = background_audio.subclip(start_time_audio,end_time_audio)
background_audio = background_audio.fx(afx.volumex,0.07)
background_audio = background_audio.subclip(start_time_audio,end_time_audio)
background_audio.write_audiofile(f"assets/temp/{id}/background.mp3")
background_video.set_audio(background_audio)

@ -177,6 +177,8 @@ def make_final_video(
screenshot_width = int((W * 45) // 100)
audio = ffmpeg.input(f"assets/temp/{reddit_id}/audio.mp3")
background_audio = ffmpeg.input(f"assets/temp/{reddit_id}/background.mp3")
final_audio = ffmpeg.filter([audio, background_audio], "amix")
image_clips = list()
@ -327,7 +329,7 @@ def make_final_video(
with ProgressFfmpeg(length, on_update_example) as progress:
ffmpeg.output(
background_clip,
audio,
final_audio,
path,
f="mp4",
**{

Loading…
Cancel
Save