diff --git a/src/clipper/argparser.py b/src/clipper/argparser.py index e5e111a..9842e7d 100644 --- a/src/clipper/argparser.py +++ b/src/clipper/argparser.py @@ -460,6 +460,19 @@ def getArgParser() -> argparse.ArgumentParser: ] ), ) + parser.add_argument( + "--h264-disable-reduce-stutter", + "-h264-drs", + dest="h264DisableReduceStutter", + action="store_true", + help=" ".join( + [ + "Disable reducing output clip sutter when using the h264 output video codec.", + "When disabled, output clips will all use the input video framerate and slowed down clips may have duplicate frames that cause some stuttering.", + "This may be useful when merging h264 videos however as in some cases keeping the same framerate results in smoother transitions between clips." + ] + ), + ) parser.add_argument( "--auto-subs-lang", "-asl", diff --git a/src/clipper/clip_maker.py b/src/clipper/clip_maker.py index 07d353a..ac14f0f 100644 --- a/src/clipper/clip_maker.py +++ b/src/clipper/clip_maker.py @@ -600,11 +600,14 @@ def getFfmpegVideoCodecH264( qmin: int, ) -> Tuple[str, str]: """Following recommendations from https://www.lighterra.com/papers/videoencodingh264""" - if mps["minterpFPS"] is not None: - fps_arg = f'-r {mps["minterpFPS"]}' - elif not mp["isVariableSpeed"]: - fps_arg = f'-r ({mps["r_frame_rate"]}*{mp["speed"]})' - else: + fps_arg = "" + if not mps["h264DisableReduceStutter"]: + if mps["minterpFPS"] is not None: + fps_arg = f'-r {mps["minterpFPS"]}' + elif not mp["isVariableSpeed"]: + fps_arg = f'-r ({mps["r_frame_rate"]}*{mp["speed"]})' + + if mp["isVariableSpeed"]: fps_arg = "-fps_mode vfr" pixel_count = mps["width"] * mps["height"]