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_USERNAME=""
REDDIT_PASSWORD=""
# Valid options are "yes" and "no" for the variable below
# Valid options are "yes" and "no"
REDDIT_2FA=""
# Valid options are "light" and "dark"
THEME=""
# Enter a subreddit, e.g. "AskReddit"
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", "OPACITY"]
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."
)

@ -8,12 +8,18 @@ from moviepy.editor import (
CompositeVideoClip,
)
from utils.console import print_step
from dotenv import load_dotenv
import os
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)
@ -24,6 +30,11 @@ 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):
@ -39,14 +50,16 @@ def make_final_video(number_of_clips):
ImageClip(f"assets/png/comment_{i}.png")
.set_duration(audio_clips[i + 1].duration)
.set_position("center")
.resize(width=W - 100),
.resize(width=W - 100)
.set_opacity(float(opacity)),
)
image_clips.insert(
0,
ImageClip(f"assets/png/title.png")
.set_duration(audio_clips[0].duration)
.set_position("center")
.resize(width=W - 100),
.resize(width=W - 100)
.set_opacity(float(opacity)),
)
image_concat = concatenate_videoclips(image_clips).set_position(
("center", "center")

Loading…
Cancel
Save