简体   繁体   English

imageio 单个帧速率

[英]imageio individual frame rates

It's easy to do a gif with the imageio module like this:使用imageio模块制作 gif 很容易,如下所示:

import imageio
imageio.mimsave(path_gif_out, paths_pngs_in, fps=2)

But is it possible to change the frame rate of the individual frames?但是是否可以更改单个帧的帧速率? For example I would like the last frame rate to appear longer;例如,我希望最后一个帧速率看起来更长; eg fps=0.2 .例如fps=0.2

The documentation for the GIF-PIL format states that the parameter duration can be used to individually set the time each frame remains in view. GIF-PIL 格式的文档指出,参数持续时间可用于单独设置每个帧保持在视图中的时间。

"duration: {float, list} The duration (in seconds) of each frame. Either specify one value that is used for all frames, or one value for each frame. Note that in the GIF format the duration/delay is expressed in hundredths of a second, which limits the precision of the duration." "duration: {float, list} 每帧的持续时间(以秒为单位)。要么指定一个用于所有帧的值,要么为每个帧指定一个值。请注意,在 GIF 格式中,持续时间/延迟以百分之一表示秒,这限制了持续时间的精度。”

If duration is not used, each frame gets a 1/fps duration as the fps parameter description says:如果不使用持续时间,则每个帧都会获得 1/fps 的持续时间,如 fps 参数描述所述:

"fps: float The number of frames per second. If duration is not given, the duration for each frame is set to 1/fps. Default 10." “fps:float每秒的帧数。如果没有给出duration,则每帧的持续时间设置为1/fps。默认10。”

Link to the imageio library documentation: https://imageio.readthedocs.io/en/stable/format_gif-pil.html#parameters-for-saving链接到 imageio 库文档: https://imageio.readthedocs.io/en/stable/format_gif-pil.html#parameters-for-saving

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM