Moved make meme function to another file

pull/2041/head
Cyteon 1 year ago committed by GitHub
parent 3a9b098716
commit baad243b22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -26,8 +26,7 @@ from video_creation.background import (
from video_creation.final_video import make_final_video
from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts
from video_creation.voices import save_text_to_mp3
from moviepy.editor import VideoFileClip, concatenate_videoclips
from video_creation.memes import make_meme_video
__VERSION__ = "3.2.1"
@ -75,34 +74,6 @@ def run_many(times) -> None:
if settings.config["settings"]["mememode"]:
make_meme_video()
def make_meme_video():
if not os.path.exists("./clipped"):
os.mkdir("./clipped")
directory = f'./results/{settings.config["reddit"]["thread"]["subreddit"]}'
print(directory)
# Get a list of all MP4 files in the directory
mp4_files = [f for f in os.listdir(directory) if f.endswith('.mp4')]
# Create a list of VideoFileClip objects
clips = [VideoFileClip(os.path.join(directory, f)) for f in mp4_files]
# Concatenate the clips into a single video
final_clip = concatenate_videoclips(clips)
# Write the final video to a file
output_file = './clipped/output.mp4'
final_clip.write_videofile(output_file)
# Close the video clips
for clip in clips:
clip.close()
# Delete the individual MP4 files
for f in mp4_files:
os.remove(os.path.join(directory, f))
def shutdown() -> NoReturn:
if "redditid" in globals():
print_markdown("## Clearing temp files")

@ -0,0 +1,31 @@
from utils import settings
from moviepy.editor import VideoFileClip, concatenate_videoclips
def make_meme_video():
if not os.path.exists("./clipped"):
os.mkdir("./clipped")
directory = f'./results/{settings.config["reddit"]["thread"]["subreddit"]}'
print(directory)
# Get a list of all MP4 files in the directory
mp4_files = [f for f in os.listdir(directory) if f.endswith('.mp4')]
# Create a list of VideoFileClip objects
clips = [VideoFileClip(os.path.join(directory, f)) for f in mp4_files]
# Concatenate the clips into a single video
final_clip = concatenate_videoclips(clips)
# Write the final video to a file
output_file = './clipped/output.mp4'
final_clip.write_videofile(output_file)
# Close the video clips
for clip in clips:
clip.close()
# Delete the individual MP4 files
for f in mp4_files:
os.remove(os.path.join(directory, f))
Loading…
Cancel
Save