Merge pull request #270 from jacesleeman/master

Allow the user to set opacity for the screenshots
pull/274/head
Callum Leslie 3 years ago committed by GitHub
commit 65afc5ccc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,11 +2,14 @@ REDDIT_CLIENT_ID=""
REDDIT_CLIENT_SECRET="" REDDIT_CLIENT_SECRET=""
REDDIT_USERNAME="" REDDIT_USERNAME=""
REDDIT_PASSWORD="" REDDIT_PASSWORD=""
# Valid options are "yes" and "no"
# Valid options are "yes" and "no" for the variable below
REDDIT_2FA="" REDDIT_2FA=""
# Valid options are "light" and "dark"
THEME="" THEME=""
# Enter a subreddit, e.g. "AskReddit" # Enter a subreddit, e.g. "AskReddit"
SUBREDDIT="" SUBREDDIT=""
# Range is 0 -> 1
OPACITY="0.9"

@ -9,6 +9,8 @@ import os, time, shutil
REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"] REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD"]
REQUIRED_VALUES = ["REDDIT_CLIENT_ID","REDDIT_CLIENT_SECRET","REDDIT_USERNAME","REDDIT_PASSWORD", "OPACITY"]
print_markdown( print_markdown(
"### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue." "### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue."
) )

@ -8,12 +8,18 @@ from moviepy.editor import (
CompositeVideoClip, CompositeVideoClip,
) )
from utils.console import print_step from utils.console import print_step
from dotenv import load_dotenv
import os
W, H = 1080, 1920 W, H = 1080, 1920
def make_final_video(number_of_clips): def make_final_video(number_of_clips):
# Calls opacity from the .env
load_dotenv()
opacity = os.getenv('OPACITY')
print_step("Creating the final video...") print_step("Creating the final video...")
VideoFileClip.reW = lambda clip: clip.resize(width=W) VideoFileClip.reW = lambda clip: clip.resize(width=W)
VideoFileClip.reH = lambda clip: clip.resize(width=H) VideoFileClip.reH = lambda clip: clip.resize(width=H)
@ -24,6 +30,11 @@ def make_final_video(number_of_clips):
.resize(height=H) .resize(height=H)
.crop(x1=1166.6, y1=0, x2=2246.6, y2=1920) .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 # Gather all audio clips
audio_clips = [] audio_clips = []
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
@ -39,14 +50,16 @@ def make_final_video(number_of_clips):
ImageClip(f"assets/png/comment_{i}.png") ImageClip(f"assets/png/comment_{i}.png")
.set_duration(audio_clips[i + 1].duration) .set_duration(audio_clips[i + 1].duration)
.set_position("center") .set_position("center")
.resize(width=W - 100), .resize(width=W - 100)
.set_opacity(float(opacity)),
) )
image_clips.insert( image_clips.insert(
0, 0,
ImageClip(f"assets/png/title.png") ImageClip(f"assets/png/title.png")
.set_duration(audio_clips[0].duration) .set_duration(audio_clips[0].duration)
.set_position("center") .set_position("center")
.resize(width=W - 100), .resize(width=W - 100)
.set_opacity(float(opacity)),
) )
image_concat = concatenate_videoclips(image_clips).set_position( image_concat = concatenate_videoclips(image_clips).set_position(
("center", "center") ("center", "center")

Loading…
Cancel
Save