Reputation: 241
Is there any tool or script for batch converting animated webp images?
I want to create animated thumbnails from my animated webp images:
I tried tools like ImageMagick, but they cannot change the frame rate.
Upvotes: 3
Views: 6994
Reputation: 32335
If you just want to change the framerate, the webpmux
tool from Google (available as the webp
package on your Linux OS) can do the job quickly and easily.
First you need to know the current duration interval for the source file - there are several ways to do that, but the webpinfo
from the same package is maybe the easiest - webpinfo source.webp
the note the duration listed for the frames.
Then calculate your new desired frame rate - if the source animation had an FPS of 10, it would show a duration of 100. To change it to 25, divide 100ms duration by 2.5 (the multiplier to go from 10 to 25), which will get you a target duration of 40ms.
Finally run webpmux -duration 40 source.webp -o destination.webp
to create a copy of the source animation with a changed interhframe duration.
Upvotes: 4
Reputation: 133853
See #4907: Support decoding animated WebP images.
Use another tool, such as anim_dump
, to extract the WebP frames. See How can I convert an animated WebP to a WebM? for more info and examples.
Once you have the frames you can use ffmpeg
.
10 fps, half size:
ffmpeg -framerate 25 -i input_%03d.webp -vf "fps=10,scale=iw/2:-1" -quality 25 output.webp
To encode WebP, ffmpeg
must be compiled with --enable-libwebp
.
Use the scale filter.
-quality
option for the encoder libwebp. Range is 0-100. Default is 75.-preset
option to match the content type.See ffmpeg -h encoder=libwebp
for more options and info.
Use the fps filter or the -r
option.
Upvotes: 0