Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.07k stars 1.51k forks source link

Unable to set FPS in GIFs #2151

Open TimSchneider42 opened 2 months ago

TimSchneider42 commented 2 months ago

Hey,

When using MoviePy to store frame sequences as GIFs, I noticed that setting the fps parameter seems to have no effect. After digging around in the code a little bit, I found the issue.

In moviepy/video/io/gif_writers.py, line 442:

writer = imageio.save(
    filename, duration=1.0 / fps, quantizer=quantizer, palettesize=colors, loop=loop
)

Here, the duration passed to imageio is in seconds, which is consistent with imageio's documentation. Unfortunately, though, the documentation is erroneous in this case, as the underlying Pillow expects milliseconds.

I believe the best course of action is to ignore the documentation of imageio and pass the value as milliseconds.

Currently, this issue affects PyTorch's SummaryWriter, which uses MoviePy to store videos as GIFs.

Best, Tim

IcarusWizard commented 2 weeks ago

I would also appreciate the bug being fixed; having tensorboard logging at the wrong fps is really annoying.

TimSchneider42 commented 2 weeks ago

I agree! @keikoro, can I help you with anything to get this pull request merged?