I need to convert several videos to animated webp format, but I found no software to handle it. There are some online tools, but they are either paid or work with restrictions like low resolution and fps.
Asked
Active
Viewed 3,837 times
1 Answers
11
Though didn't find a software with GUI that can to the converting, I tried the ffmpeg CLI method and it works for me.
1. Install ffmpeg CLI through homebrew
In terminal.app, install ffmpeg through homebrew
brew install ffmpeg
Validate the installation:
which ffmpeg
Expect to see terminal returns the directory path of ffmpeg such as /usr/local/bin/ffmpeg
2. Run and convert
Example command which would convert an mp4 file to a lossless loop playing webp file in 20FPS with resolution 800px(width) * h600px(height):
ffmpeg -i input_filename.mp4 -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 800:600 output_filename.webp
primary options:
- set frame per second as 20:
-filter:v fps=fps=20
- set output file lossless:
-lossless 1
- set output webp file loop play:
-loop 0
. For non-loop, use-loop 1
- set rendering mode
-preset default
, can set aspicture
,photo
,text
,icon
,drawing
andnone
as needed. It would effect output file size. http://ffmpeg.org/ffmpeg-all.html#Options-28 - set output webp resolution as w800px * h600px
-s 800:600
For more option details, please visit the the ffmpeg libwebp documentation
This method should applicable for majority video formats including .mov, .avi, .flv, etc. as input files as well as .gif format as output file.
Noted this on my gist: https://gist.github.com/witmin/1edf926c2886d5c8d9b264d70baf7379

Milllie
- 126
- 2
- 4
-
Is the webp supposed to be bigger in size compared to the original size of the mp4 ? I have a 780kb mp4 that is turning into a 6mb video with the same commands you posted. – zd5151 Oct 26 '20 at 00:36
-
@zd5151 yes it could be bigger if -lossless, bigger resolution or higher frame rate. The fps may effect the most. – Milllie Oct 27 '20 at 06:19
-
@Milllie when i convert mp4 to animated webp it increases size from 500kb to 1.5mb, any suggestion or solution? – Addy Nov 02 '21 at 12:40
-
@Addy unfortunately I also met the same problem :( – Milllie Nov 03 '21 at 13:19