我可以加入不同速度或延迟的 gif 吗?

Can I join gifs with different speed or delay?

我尝试加入两个具有不同延迟的不同 gif,但最终 output.gif 具有相同的延迟,没有区别...有没有办法在一个 gif 中具有不同的延迟?

import subprocess
import os


def mk(i, o, delay=100):
    subprocess.call("convert -delay " +
                    delay + " -loop 5 " + i + " " + o, shell=True)


delay = input("Delay (default 100): ")
# mk("*png", "gif1, delay) # I used this to make the 2 gif
# with a delay of 100 and 30 respectively
# and then I joined them with the code below, but I dunno how to
# give them a separate delay... I want them one after the other
# in order of time
mk("*.gif", "output.gif", delay)
os.system("start output.gif")

延迟是一个设置,因此它适用于它之后的所有图像,并保持设置直到您更改它。

所以让我们制作一个红色、绿色和蓝色的图像:

convert -size 400x250 xc:red  f1.gif
convert -size 400x250 xc:lime f2.gif
convert -size 400x250 xc:blue f3.gif

现在将延迟设置为 100 并为前三个设置动画,然后将其设置为 300 并再次为相同的三个设置动画,但这次使用新的延迟:

convert -delay 100 f1.gif f2.gif f3.gif \
        -delay 300 f1.gif f2.gif f3.gif animated.gif

现在检查与各种帧相关的延迟:

identify -format "%f[%s] %T\n" animated.gif
animated.gif[0] 100
animated.gif[1] 100
animated.gif[2] 100
animated.gif[3] 300
animated.gif[4] 300
animated.gif[5] 300

所以我猜你想要的是:

convert -delay 200 1.gif -coalesce \( -delay 30 2.gif -coalesce \) animated.gif