Merge pull request #333 from DomizianoScarcelli/change-video-location

Added a .env variable to change the save location of the final video
This commit is contained in:
Callum Leslie authored and GitHub committed 2022-06-07 23:29:10 +01:00
commit 757477cee8
2 files changed
+15 -5

No files matched your search

+4
View File
@@ -23,3 +23,7 @@ COMMENT_LENGTH_RANGE = "min,max"
# Range is 0 -> 1
OPACITY="0.9"
# The absolute path of the folder where you want to save the final video
# If empty or wrong, the path will be 'assets/'
FINAL_VIDEO_PATH=""
+11 -5
View File
@@ -10,7 +10,7 @@ from moviepy.editor import (
)
import reddit.subreddit
import re
from utils.console import print_step
from utils.console import print_step, print_substep
from dotenv import load_dotenv
import os
@@ -80,9 +80,15 @@ def make_final_video(number_of_clips):
)
image_concat.audio = audio_composite
final = CompositeVideoClip([background_clip, image_concat])
filename = re.sub(
'[?"%*:|<>]', "", ("assets/" + reddit.subreddit.submission.title + ".mp4")
)
final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k")
final_video_path = "assets/"
if os.getenv("FINAL_VIDEO_PATH"):
final_video_path = os.getenv("FINAL_VIDEO_PATH")
filename = (re.sub('[?\"%*:|<>]', '', (final_video_path + reddit.subreddit.submission.title + ".mp4")))
try:
final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k")
except:
print_substep("Something's wrong with the path you inserted, the video will be saved in the default path (assets/)", style="bold red")
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