From 59d07f51c8719dc088313b55f263dc1bea19ecce Mon Sep 17 00:00:00 2001 From: William9923 Date: Mon, 4 Jul 2022 04:34:08 +0700 Subject: [PATCH] chore: fixup changes after rebase --- video_creation/final_video.py | 43 ++++++++++++----------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index f2f12c8..428dd67 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -3,7 +3,6 @@ import multiprocessing import os import re from os.path import exists -from typing import Dict from typing import Tuple, Any from moviepy.editor import ( @@ -28,7 +27,7 @@ console = Console() W, H = 1080, 1920 -def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str], background_config: Tuple[str, str, str, Any]): +def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, background_config: Tuple[str, str, str, Any]): """Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp Args: @@ -57,37 +56,23 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict[str], b # add title to video image_clips = [] # Gather all images - if opacity is None or float(opacity) >= 1: # opacity not set or is set to one OR MORE - image_clips.insert( - 0, - ImageClip("assets/temp/png/title.png") - .set_duration(audio_clips[0].duration) - .resize(width=W - 100), - ) - else: - image_clips.insert( - 0, - ImageClip("assets/temp/png/title.png") - .set_duration(audio_clips[0].duration) + new_opacity = 1 if opacity is None or float(opacity) >= 1 else float(opacity) + image_clips.insert( + 0, + ImageClip("assets/temp/png/title.png") + .set_duration(audio_clips[0].duration) + .resize(width=W - 100) + .set_opacity(new_opacity) + ) + + for i in range(0, number_of_clips): + image_clips.append( + ImageClip(f"assets/temp/png/comment_{i}.png") + .set_duration(audio_clips[i + 1].duration) .resize(width=W - 100) .set_opacity(new_opacity) ) - for i in range(0, number_of_clips): - if opacity is None or float(opacity) >= 1: # opacity not set or is set to one OR MORE - image_clips.append( - ImageClip(f"assets/temp/png/comment_{i}.png") - .set_duration(audio_clips[i + 1].duration) - .resize(width=W - 100), - ) - else: - image_clips.append( - ImageClip(f"assets/temp/png/comment_{i}.png") - .set_duration(audio_clips[i + 1].duration) - .resize(width=W - 100) - .set_opacity(float(opacity)), - ) - # if os.path.exists("assets/mp3/posttext.mp3"): # image_clips.insert( # 0,