alexwlchan / create_thumbnail

A simple command-line tool for creating image thumbnails
1 stars 0 forks source link

Add support for animated WebP images #9

Open alexwlchan opened 2 months ago

alexwlchan commented 2 months ago

Prompted by discovering one such image in my collection.

This isn't widespread yet so it's not a priority, but it'd be nice.

alexwlchan commented 2 months ago

I had an initial attempt at this in #10, but it turns out the ffmpeg command for creating MP4 videos from animated GIFs doesn't work for animated WebP (at least, not yet).

alexwlchan commented 2 months ago

There's a suggestion in this Reddit thread that I extract the frames and then feed them into ffmpeg – the issue is that ffmpeg doesn't have a WebP decoder, but I have one in the image crate: https://www.reddit.com/r/ffmpeg/comments/14xqbia/convert_animated_webp_to_mp4/

What I can't work out is whether I can get the timing information that way.

Also it turns out there's a method called is_animated() which I should probably use instead of inspecting the frames directly: https://docs.rs/image/0.25.2/image/codecs/webp/struct.WebPDecoder.html#method.has_animation

alexwlchan commented 2 months ago

There's another crate with WebP support using a C library, and it exposes the timestamp of individual frames: https://docs.rs/webp-animation/latest/webp_animation/struct.Frame.html#method.timestamp

alexwlchan commented 2 months ago

For when I get round to this: here's an example of an animated WebP I can use for testing.

animated-webp-supported.webp.zip