简体   繁体   中英

imageio individual frame rates

It's easy to do a gif with the imageio module like this:

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 .

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.

"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."

If duration is not used, each frame gets a 1/fps duration as the fps parameter description says:

"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."

Link to the imageio library documentation: https://imageio.readthedocs.io/en/stable/format_gif-pil.html#parameters-for-saving

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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