How can I convert an animated WebP to a WebM?
5,588
Since there does not appear to be any widely-supported way to do it yet:
- Install the
anim_dump
example utility from libwebp, since it is not included in thewebp
package.- Clone the repo:
git clone https://chromium.googlesource.com/webm/libwebp && cd libwebp
. - Force
make
to buildanim_dump
:echo "bin_PROGRAMS += anim_dump" >> examples/Makefile.am
. - Install libwebp:
./autogen.sh && ./configure && make && sudo make install
. -
Add
/usr/local/lib
to your linker path:echo "/usr/local/lib" |
sudo tee -a /etc/ld.so.conf
&& sudo ldconfig
. Without this,anim_dump
will not run.
- Clone the repo:
- Extract the WebP frames to PNGs using
anim_dump
.mkdir frames && cd frames && anim_dump ../example.webp && cd ..
. - Figure out the framerate of the video using
webpmux
:webpmux -info ../example.webp
. Use about the average duration of the WebP frames as your WebM framerate. If your WebP does not use a consistent framerate, you'll have to manually deal with the durations somehow. - Create a WebM using ffmpeg:
ffmpeg -framerate <my-framerate> -i frames/dump_%04d.png example.webm
- Clean up:
rm -r frames/
.
Related videos on Youtube
Author by
James Martin
Updated on September 18, 2022Comments
-
James Martin over 1 year
I would like to convert an animated WebP file to a WebM. However, most tools only support converting to an animated WebP but not back, when they support animated WebPs at all: ImageMagick's
convert
does not support animated WebP,ffmpeg
does not support animated WebP, andwebpmux
only supports extracting a single frame at a time (as far as I can tell).How can I go about making that conversion?