Fixed issues and improvements related by Jason

pull/1593/head
Lucas 2 years ago
parent 778d9c0c37
commit d8347e08b9

@ -51,10 +51,11 @@ def main(POST_ID=None) -> None:
redditid = id(reddit_object)
length, number_of_comments = save_text_to_mp3(reddit_object)
length = math.ceil(length)
bg_config = {}
get_screenshots_of_reddit_posts(reddit_object, number_of_comments)
bg_config["video"] = get_background_config("video")
bg_config["audio"] = get_background_config("audio")
bg_config = {
"video": get_background_config("video"),
"audio": get_background_config("audio"),
}
download_background_video(bg_config["video"])
download_background_audio(bg_config["audio"])
chop_background(bg_config, length, reddit_object)

@ -22,8 +22,8 @@ def load_background_options():
background_options["audio"] = json.load(json_file)
# Remove "__comment" from backgrounds
background_options["video"].pop("__comment", None)
background_options["audio"].pop("__comment", None)
del background_options["video"]["__comment"]
del background_options["audio"]["__comment"]
# Add position lambda function
# (https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html#moviepy.video.VideoClip.VideoClip.set_position)

@ -285,11 +285,11 @@ def make_final_video(
subreddit = settings.config["reddit"]["thread"]["subreddit"]
if not exists(f"./results/{subreddit}"):
print_substep("The 'results' folder didn't exist so I made it")
print_substep("The 'results' folder could not be found so it was automatically created.")
os.makedirs(f"./results/{subreddit}")
if not exists(f"./results/{subreddit}/OnlyTTS") and allowOnlyTTSFolder:
print_substep("The 'OnlyTTS' folder didn't exist so I made it")
print_substep("The 'OnlyTTS' folder could not be found so it was automatically created.")
os.makedirs(f"./results/{subreddit}/OnlyTTS")
# create a thumbnail for the video
@ -297,7 +297,7 @@ def make_final_video(
if settingsbackground["background_thumbnail"]:
if not exists(f"./results/{subreddit}/thumbnails"):
print_substep("The results/thumbnails folder didn't exist so I made it")
print_substep("The 'results/thumbnails' folder could not be found so it was automatically created.")
os.makedirs(f"./results/{subreddit}/thumbnails")
# get the first file with the .png extension from assets/backgrounds and use it as a background for the thumbnail
first_image = next(
@ -351,13 +351,14 @@ def make_final_video(
old_percentage = pbar.n
pbar.update(status - old_percentage)
path = f"results/{subreddit}"
defaultPath = f"results/{subreddit}"
with ProgressFfmpeg(length, on_update_example) as progress:
path = defaultPath + f"/{filename}"
path = path[:251] + ".mp4" #Prevent a error by limiting the path length, do not change this.
ffmpeg.output(
background_clip,
final_audio,
path+f"/{filename}.mp4",
path,
f="mp4",
**{
"c:v": "h264",
@ -374,12 +375,14 @@ def make_final_video(
old_percentage = pbar.n
pbar.update(100 - old_percentage)
if(allowOnlyTTSFolder):
path = defaultPath + f"/OnlyTTS/{filename}"
path = path[:251] + ".mp4" #Prevent a error by limiting the path length, do not change this.
print_step("Rendering the Only TTS Video 🎥")
with ProgressFfmpeg(length, on_update_example) as progress:
ffmpeg.output(
background_clip,
audio,
path+f"/OnlyTTS/{filename}.mp4",
path,
f="mp4",
**{
"c:v": "h264",

Loading…
Cancel
Save