From 612708216ce5f88039ae385c09687e2839287b94 Mon Sep 17 00:00:00 2001 From: dura Date: Sun, 4 Feb 2024 15:33:35 +0100 Subject: [PATCH] Tune x264 parameters to reduce resulting file size --- src/videojitter/generate_video.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/videojitter/generate_video.py b/src/videojitter/generate_video.py index 64652f3..1616c2f 100644 --- a/src/videojitter/generate_video.py +++ b/src/videojitter/generate_video.py @@ -71,6 +71,14 @@ def _parse_arguments(): ), default="5", ) + argument_parser.add_argument( + "--fastest-encoding", + help=( + "Enables fastest encoding speed (about 1.5x faster) at the expense of" + " generated file size (about 8x bigger)." + ), + action="store_true", + ) return argument_parser.parse_args() @@ -125,8 +133,9 @@ def color_input(color): args.output_file, **{ "shortest": None, - "profile:v": "baseline", - "preset": "ultrafast", + "profile:v": "baseline" if args.fastest_encoding else "main", + "preset": "ultrafast" if args.fastest_encoding else "superfast", + "x264-params": "" if args.fastest_encoding else "bframes=0", # Make the video behave like typical HD video for compatibility and to # ensure the video players behave similarly to a "real" video. "pix_fmt": "yuv420p",