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:

  1. Install the anim_dump example utility from libwebp, since it is not included in the webp package.
    1. Clone the repo:git clone https://chromium.googlesource.com/webm/libwebp && cd libwebp.
    2. Force make to build anim_dump: echo "bin_PROGRAMS += anim_dump" >> examples/Makefile.am.
    3. Install libwebp: ./autogen.sh && ./configure && make && sudo make install.
    4. 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.
  2. Extract the WebP frames to PNGs using anim_dump. mkdir frames && cd frames && anim_dump ../example.webp && cd ...
  3. 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.
  4. Create a WebM using ffmpeg: ffmpeg -framerate <my-framerate> -i frames/dump_%04d.png example.webm
  5. Clean up: rm -r frames/.
Share:
5,588

Related videos on Youtube

James Martin
Author by

James Martin

Updated on September 18, 2022

Comments

  • James Martin
    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, and webpmux only supports extracting a single frame at a time (as far as I can tell).

    How can I go about making that conversion?