diff --git a/cli.py b/cli.py index ccaec75..bfded52 100644 --- a/cli.py +++ b/cli.py @@ -32,12 +32,22 @@ def program_options(): help="Use another video background for video (accepts link).", action="store" ) + parser.add_argument( + "-f", + "--filename", + help="Set a filename for the video.", + action="store" + ) args = parser.parse_args() try: if args.create: - main(args.subreddit, args.background) + main( + args.subreddit, + args.background, + args.filename + ) else: print_substep("Error occured!", style="bold red") raise SystemExit() diff --git a/main.py b/main.py index 36e1c1c..c780dde 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,7 @@ from video_creation.final_video import make_final_video from utils.console import print_markdown, print_substep -def main(subreddit_=None, background=None): +def main(subreddit_=None, background=None, filename=None): REQUIRED_VALUES = [ "REDDIT_CLIENT_ID", "REDDIT_CLIENT_SECRET", @@ -42,7 +42,10 @@ def main(subreddit_=None, background=None): if configured: reddit_object = get_subreddit_threads(subreddit_) length, number_of_comments = save_text_to_mp3(reddit_object) - download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME")) + download_screenshots_of_reddit_posts( + reddit_object, number_of_comments, + os.getenv("THEME") + ) download_background(background) chop_background_video(length) - final_video = make_final_video(number_of_comments) + final_video = make_final_video(snumber_of_comments, filename) diff --git a/video_creation/final_video.py b/video_creation/final_video.py index bdf36ad..599026c 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -19,7 +19,7 @@ from utils.console import print_step W, H = 1080, 1920 -def make_final_video(number_of_clips): +def make_final_video(number_of_clips, file_name): # Calls opacity from the .env load_dotenv() opacity = os.getenv('OPACITY') @@ -80,9 +80,11 @@ def make_final_video(number_of_clips): image_concat.audio = audio_composite final = CompositeVideoClip([background_clip, image_concat]) - filename = ( - re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4")) - ) + if file_name is None: + filename = ( + re.sub('[?\"%*:|<>]', '', ("assets/" + reddit.subreddit.submission.title + ".mp4")) + ) + final.write_videofile(filename, fps=30, audio_codec="aac", audio_bitrate="192k") for i in range(0, number_of_clips): pass