From 136b7d40b502053acef2d7247a5274a0681f5aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 11 Feb 2026 12:03:06 +0100 Subject: [PATCH] [pp:ugoira] fix processing '.gif' frames use 'concat' demuxer to combine frames for mkvmerge https://github.com/danbooru/danbooru/pull/6103 https://github.com/danbooru/danbooru/pull/6241 --- gallery_dl/postprocessor/ugoira.py | 23 +++++++++++++---------- test/results/pixiv.py | 14 +++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index 3813faec..d3aa0d2e 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018-2025 Mike Fährmann +# Copyright 2018-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -352,14 +352,13 @@ class UgoiraPP(PostProcessor): def _process_mkvmerge(self, pathfmt, tempdir): self._realpath = pathfmt.realpath - pathfmt.realpath = tempdir + "/temp." + self.extension + pathfmt.realpath = f"{tempdir}/temp.{self.extension}" return [ self.ffmpeg, - "-f", "image2", - "-pattern_type", "sequence", - "-i", (f"{tempdir.replace('%', '%%')}/%06d." - f"{self._frames[0]['file'].rpartition('.')[2]}"), + "-r", "25", + "-f", "concat", + "-i", self._write_ffmpeg_concat(tempdir, False), ] def _finalize_mkvmerge(self, pathfmt, tempdir): @@ -375,12 +374,16 @@ class UgoiraPP(PostProcessor): pathfmt.realpath = self._realpath self._exec(args) - def _write_ffmpeg_concat(self, tempdir): + def _write_ffmpeg_concat(self, tempdir, duration=True): content = ["ffconcat version 1.0"] - for frame in self._frames: - content.append(f"file '{frame['file']}'\n" - f"duration {frame['delay'] / 1000}") + if duration: + for frame in self._frames: + content.append(f"file '{frame['file']}'\n" + f"duration {frame['delay'] / 1000}") + else: + for frame in self._frames: + content.append(f"file '{frame['file']}'") if self.repeat: content.append(f"file '{frame['file']}'") content.append("") diff --git a/test/results/pixiv.py b/test/results/pixiv.py index c65dcf94..09f216ea 100644 --- a/test/results/pixiv.py +++ b/test/results/pixiv.py @@ -276,7 +276,7 @@ __tests__ = ( { "#url" : "https://www.pixiv.net/artworks/101003492", - "#comment" : "original ugoira frames (#6056)", + "#comment" : "ugoira - original '.png' frames (#6056)", "#class" : pixiv.PixivWorkExtractor, "#options" : {"ugoira": "original"}, "#results" : ( @@ -292,6 +292,18 @@ __tests__ = ( "count" : 6, }, +{ + "#url" : "https://www.pixiv.net/en/artworks/108469527", + "#comment" : "ugoira - '.gif' frames", + "#class" : pixiv.PixivWorkExtractor, + "#options" : {"ugoira": "original"}, + "#pattern" : r"https://i\.pximg\.net/img\-original/img/2023/05/27/02/23/48/108469527_ugoira\d+\.gif", + "#count" : 30, + + "frames": list, + "count" : 30, +}, + { "#url" : "https://www.pixiv.net/artworks/966412", "#comment" : "related works (#1237)",