Track more progress

pull/1873/head
KyleBoyer 2 years ago
parent e04883563e
commit 1ddf28fd19

@ -13,6 +13,8 @@ from utils.console import print_step, print_substep
import yt_dlp
import ffmpeg
from utils.ffmpeg import ffmpeg_progress_run
def load_background_options():
background_options = {}
@ -145,12 +147,15 @@ def chop_background(background_config: Dict[str, Tuple], video_length: int, redd
audio_file_path,
stream_loop=background_audio_loops
)
ffmpeg.output(
background_audio_loop_input,
background_looped_audio_file_path,
vcodec="copy",
acodec="copy"
).overwrite_output().run(quiet=True)
ffmpeg_progress_run(
ffmpeg.output(
background_audio_loop_input,
background_looped_audio_file_path,
vcodec="copy",
acodec="copy"
).overwrite_output(),
background_audio_loops*background_audio_duration
)
audio_file_path = background_looped_audio_file_path
print_step("Finding a spot in the background audio to chop...✂️")
background_audio = AudioFileClip(audio_file_path)
@ -173,12 +178,15 @@ def chop_background(background_config: Dict[str, Tuple], video_length: int, redd
video_file_path,
stream_loop=background_video_loops
)
ffmpeg.output(
background_video_loop_input,
background_looped_video_file_path,
vcodec="copy",
acodec="copy"
).overwrite_output().run(quiet=True)
ffmpeg_progress_run(
ffmpeg.output(
background_video_loop_input,
background_looped_video_file_path,
vcodec="copy",
acodec="copy"
).overwrite_output(),
background_video_loops*background_video_duration
)
video_file_path = background_looped_video_file_path
print_step("Finding a spot in the background video to chop...✂️")

@ -119,6 +119,7 @@ def make_final_video(
# Gather all audio clips
audio_clips = list()
audio_clips_durations = list()
if number_of_clips == 0 and settings.config["settings"]["storymode"] == "false":
print(
"No audio clips to gather. Please use a different TTS or post."
@ -128,6 +129,11 @@ def make_final_video(
if settings.config["settings"]["storymodemethod"] == 0:
audio_clips = [ffmpeg.input(f"assets/temp/{reddit_id}/mp3/title.mp3")]
audio_clips.insert(1, ffmpeg.input(f"assets/temp/{reddit_id}/mp3/postaudio.mp3"))
audio_clips_durations = [
get_duration(f"assets/temp/{reddit_id}/mp3/title.mp3"),
get_duration(f"assets/temp/{reddit_id}/mp3/postaudio.mp3")
]
elif settings.config["settings"]["storymodemethod"] == 1:
audio_clips = [
ffmpeg.input(f"assets/temp/{reddit_id}/mp3/postaudio-{i}.mp3")
@ -135,6 +141,15 @@ def make_final_video(
]
audio_clips.insert(0, ffmpeg.input(f"assets/temp/{reddit_id}/mp3/title.mp3"))
audio_clips_durations = [
get_duration(f"assets/temp/{reddit_id}/mp3/postaudio-{i}.mp3")
for i in track(range(number_of_clips + 1), "Calculating the audio file durations...")
]
audio_clips_durations.insert(
0,
get_duration(f"assets/temp/{reddit_id}/mp3/title.mp3")
)
else:
audio_clips = [
ffmpeg.input(f"assets/temp/{reddit_id}/mp3/{i}.mp3") for i in range(number_of_clips)
@ -150,11 +165,14 @@ def make_final_video(
get_duration(f"assets/temp/{reddit_id}/mp3/title.mp3")
)
audio_concat = ffmpeg.concat(*audio_clips, a=1, v=0)
ffmpeg.output(
audio_concat, f"assets/temp/{reddit_id}/audio.mp3", **{"b:a": "192k"}
).overwrite_output().run(quiet=True)
ffmpeg_progress_run(
ffmpeg.output(
audio_concat, f"assets/temp/{reddit_id}/audio.mp3", **{"b:a": "192k"}
).overwrite_output(),
sum(audio_clips_durations)
)
print_substep(f"Video will be: {format_timespan(length)}", style="bold green")
print_substep(f"Video will be {format_timespan(length)} long", style="bold green")
screenshot_width = int((W * 45) // 100)
audio = ffmpeg.input(f"assets/temp/{reddit_id}/audio.mp3")

Loading…
Cancel
Save