From d56f957ce730eca62dc9a80fa26b8b852eba817d Mon Sep 17 00:00:00 2001 From: Theelgirl <43764914+Theelgirl@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:05:21 +0000 Subject: [PATCH] Allow a user to set framerate for encoding with -f You might want to format line 203 over two lines. Also I made make_video's new framerate argument default to 1/5 in case it's ever called by a function besides main. --- fvid/fvid.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fvid/fvid.py b/fvid/fvid.py index 716bc74..cfce93c 100644 --- a/fvid/fvid.py +++ b/fvid/fvid.py @@ -157,7 +157,7 @@ def make_image_sequence(bitstring, resolution=(1920, 1080)): return image_sequence -def make_video(output_filepath, image_sequence): +def make_video(output_filepath, image_sequence, framerate="1/5"): frames = glob.glob(f"{FRAMES_DIR}encoded_frames*.png") @@ -171,7 +171,7 @@ def make_video(output_filepath, image_sequence): ffmpeg.input( f"{FRAMES_DIR}encoded_frames*.png", pattern_type="glob", - framerate="1/5", + framerate=framerate, ).output(output_filepath, vcodec="libx264rgb").run(quiet=True) @@ -200,6 +200,7 @@ def main(): parser.add_argument("-i", "--input", help="input file", required=True) parser.add_argument("-o", "--output", help="output path") + parser.add_argument("-f", "--framerate", help="set framerate for encoding (as a fraction)", action='store_const', const="1/5", type=str) args = parser.parse_args() @@ -237,6 +238,6 @@ def main(): else: video_file_path = "./file.mp4" - make_video(video_file_path, image_sequence) + make_video(video_file_path, image_sequence, args.framerate) cleanup()