From 7c2c6db1c41ef763a84aa54b6f4f5afc5df11281 Mon Sep 17 00:00:00 2001 From: Xpl0itU Date: Wed, 28 Dec 2022 15:43:59 +0100 Subject: [PATCH] Improve speed and audio quality --- video_creation/final_video.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 403a136..f220748 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -50,7 +50,7 @@ def name_normalize(name: str) -> str: def prepare_background(reddit_id: str, W: int, H: int) -> str: output_path = f"assets/temp/{reddit_id}/background_noaudio.mp4" - output = ffmpeg.input(f"assets/temp/{reddit_id}/background.mp4").filter('crop', "ih*(9/16)", "ih").output(output_path, an=None, **{"c:v": "h264", "b:v": "8M", "b:a": "192k"}).overwrite_output() + output = ffmpeg.input(f"assets/temp/{reddit_id}/background.mp4").filter('crop', "ih*(9/16)", "ih").output(output_path, an=None, **{"c:v": "h264", "b:v": "8M", "b:a": "192k", "threads": multiprocessing.cpu_count()}).overwrite_output() output.run() return output_path @@ -99,7 +99,7 @@ def make_final_video( audio_clips_durations = [float(ffmpeg.probe(f"assets/temp/{reddit_id}/mp3/{i}.mp3")['format']['duration']) for i in range(number_of_clips)] audio_clips_durations.insert(0, float(ffmpeg.probe(f"assets/temp/{reddit_id}/mp3/title.mp3")['format']['duration'])) audio_concat = ffmpeg.concat(*audio_clips, a=1, v=0) - ffmpeg.output(audio_concat, f"assets/temp/{reddit_id}/audio.mp3").overwrite_output().run() + ffmpeg.output(audio_concat, f"assets/temp/{reddit_id}/audio.mp3", **{"b:a": "192k"}).overwrite_output().run() console.log(f"[bold green] Video Will Be: {length} Seconds Long") # Gather all images @@ -151,7 +151,7 @@ def make_final_video( filename = f"{name_normalize(title)[:251]}" subreddit = settings.config["reddit"]["thread"]["subreddit"] - final = ffmpeg.output(background_clip, audio, f"results/{subreddit}/{filename}.mp4", f='mp4', **{"c:v": "h264", "b:v": "8M", "b:a": "192k"}).overwrite_output() + final = ffmpeg.output(background_clip, audio, f"results/{subreddit}/{filename}.mp4", f='mp4', **{"c:v": "h264", "b:v": "8M", "b:a": "192k", "threads": multiprocessing.cpu_count()}).overwrite_output() if not exists(f"./results/{subreddit}"): print_substep("The results folder didn't exist so I made it")