|
|
|
@ -7,6 +7,8 @@ from moviepy.editor import (
|
|
|
|
|
CompositeAudioClip,
|
|
|
|
|
CompositeVideoClip,
|
|
|
|
|
)
|
|
|
|
|
import reddit.subreddit
|
|
|
|
|
import re
|
|
|
|
|
from utils.console import print_step
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
import os
|
|
|
|
@ -16,11 +18,13 @@ W, H = 1080, 1920
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_final_video(number_of_clips):
|
|
|
|
|
|
|
|
|
|
# Calls opacity from the .env
|
|
|
|
|
load_dotenv()
|
|
|
|
|
opacity = os.getenv('OPACITY')
|
|
|
|
|
|
|
|
|
|
print_step("Creating the final video...")
|
|
|
|
|
|
|
|
|
|
VideoFileClip.reW = lambda clip: clip.resize(width=W)
|
|
|
|
|
VideoFileClip.reH = lambda clip: clip.resize(width=H)
|
|
|
|
|
|
|
|
|
@ -30,11 +34,7 @@ def make_final_video(number_of_clips):
|
|
|
|
|
.resize(height=H)
|
|
|
|
|
.crop(x1=1166.6, y1=0, x2=2246.6, y2=1920)
|
|
|
|
|
)
|
|
|
|
|
try:
|
|
|
|
|
float(os.getenv("OPACITY"))
|
|
|
|
|
except:
|
|
|
|
|
print(f"Please ensure that OPACITY is set between 0 and 1 in your .env file")
|
|
|
|
|
configured = False
|
|
|
|
|
|
|
|
|
|
# Gather all audio clips
|
|
|
|
|
audio_clips = []
|
|
|
|
|
for i in range(0, number_of_clips):
|
|
|
|
@ -66,9 +66,7 @@ def make_final_video(number_of_clips):
|
|
|
|
|
)
|
|
|
|
|
image_concat.audio = audio_composite
|
|
|
|
|
final = CompositeVideoClip([background_clip, image_concat])
|
|
|
|
|
final.write_videofile(
|
|
|
|
|
"assets/final_video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
filename = (re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4")))
|
|
|
|
|
final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k")
|
|
|
|
|
for i in range(0, number_of_clips):
|
|
|
|
|
pass
|
|
|
|
|