Merge pull request #526 from JasonLovesDoggo/master

fixed audio/video desyncing error
pull/524/head
Jason 2 years ago committed by GitHub
commit 6269686b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,7 @@ def get_subreddit_undone(submissions: List, subreddit):
print_substep("NSFW Post Detected. Skipping...") print_substep("NSFW Post Detected. Skipping...")
continue continue
return submission return submission
print('all submissions have been done going by top submission order')
return get_subreddit_undone( return get_subreddit_undone(
subreddit.top(time_filter="hour"), subreddit subreddit.top(time_filter="hour"), subreddit
) # all of the videos in hot have already been done ) # all of the videos in hot have already been done

@ -13,17 +13,12 @@ from moviepy.editor import (
CompositeAudioClip, CompositeAudioClip,
CompositeVideoClip, CompositeVideoClip,
) )
import reddit.subreddit
import re
from utils.console import print_step, print_substep
from dotenv import load_dotenv
import os
from moviepy.video.io import ffmpeg_tools from moviepy.video.io import ffmpeg_tools
from rich.console import Console
from reddit import subreddit from reddit import subreddit
from utils.cleanup import cleanup from utils.cleanup import cleanup
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
from rich.console import Console
console = Console() console = Console()
@ -57,11 +52,31 @@ def make_final_video(number_of_clips, length):
# Output Length # Output Length
console.log(f"[bold green] Video Will Be: {int_total_length} Seconds Long") console.log(f"[bold green] Video Will Be: {int_total_length} Seconds Long")
# Gather all images # add title to video
image_clips = [] 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(f"assets/temp/png/title.png")
.set_duration(audio_clips[0].duration)
.set_position("center")
.resize(width=W - 100)
.set_opacity(float(opacity)),
)
else:
image_clips.insert(
0,
ImageClip(f"assets/temp/png/title.png")
.set_duration(audio_clips[0].duration)
.set_position("center")
.resize(width=W - 100))
for i in range(0, number_of_clips): for i in range(0, number_of_clips):
if ( if (
opacity is None or float(opacity) >= 1 opacity is None or float(opacity) >= 1
): # opacity not set or is set to one OR MORE ): # opacity not set or is set to one OR MORE
image_clips.append( image_clips.append(
ImageClip(f"assets/temp/png/comment_{i}.png") ImageClip(f"assets/temp/png/comment_{i}.png")
@ -77,17 +92,7 @@ def make_final_video(number_of_clips, length):
.resize(width=W - 100) .resize(width=W - 100)
.set_opacity(float(opacity)), .set_opacity(float(opacity)),
) )
if (
opacity is None or float(opacity) >= 1
): # opacity not set or is set to one OR MORE
image_clips.insert(
0,
ImageClip(f"assets/temp/png/title.png")
.set_duration(audio_clips[0].duration)
.set_position("center")
.resize(width=W - 100)
.set_opacity(float(opacity)),
)
# if os.path.exists("assets/mp3/posttext.mp3"): # if os.path.exists("assets/mp3/posttext.mp3"):
# image_clips.insert( # image_clips.insert(
# 0, # 0,
@ -98,12 +103,6 @@ def make_final_video(number_of_clips, length):
# .set_opacity(float(opacity)), # .set_opacity(float(opacity)),
# ) # )
# else: # else:
image_clips.insert(
0,
ImageClip("assets/temp/png/title.png").set_duration(audio_clips[0].duration)
# .set_duration(audixc vcco_clips[0].duration)
.set_position("center").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