diff --git a/video_to_gif2.py b/video_to_gif2.py index bfff418..b38d2b2 100644 --- a/video_to_gif2.py +++ b/video_to_gif2.py @@ -20,6 +20,8 @@ def get_args() -> Dict[str, Any]: default='12', help='framerate of GIF (default: 12)') parser.add_argument('-e', '--extra', default=False, action='store_true', \ help='increase quality at the expense of file size and encoding time') + parser.add_argument('--no_loop', default=False, action='store_true', \ + help='don\'t loop the animated GIF') parser.add_argument('-t', '--tag', type=str, default=get_tag(), \ help='optional tag included in file name') return vars(parser.parse_args()) @@ -44,6 +46,7 @@ def generate_gif_files(inputs: List[str], args: Dict[str, Any]) -> Dict[str, Tup width = args['width'] framerate = args['framerate'] extra = args['extra'] + no_loop = args['no_loop'] extra_cmd = '' quality = '90' @@ -51,14 +54,15 @@ def generate_gif_files(inputs: List[str], args: Dict[str, Any]) -> Dict[str, Tup extra_cmd = '--extra' quality = '100' + no_loop_cmd = '' + if no_loop: no_loop_cmd = '--repeat -1' + output_map = {} for input in inputs: file_name = f"{Path(input).stem}_{tag}.gif" full_path = f"{Path(input).parent}/{file_name}" - if extra: - ex_cmd = '--extra' - command = ['-i', input, '-pix_fmt', 'yuv444p', '-f', 'yuv4mpegpipe', '-', '|', 'gifski', \ - '--width', f"{width}", '-r', f"{framerate}", extra_cmd, '-Q', quality, \ + command = ['-i', input, '-pix_fmt', 'yuv422p', '-f', 'yuv4mpegpipe', '-', '|', 'gifski', \ + '--width', f"{width}", '-r', f"{framerate}", extra_cmd, '-Q', quality, no_loop_cmd, \ '-o', f"{full_path}", '-'] command = list(filter(None, command)) success = call_ffmpeg(command)