I'm not sure how I feel about cohost allowing animated webps. I don't know how hard it is to allow static but not animated, especially since the site's thumbnailing uses webp, but I feel like the ability to use webp maliciously is just as high as mp4 if not more.
I think I'm mostly just irritated because it's a lot harder to export to for most people and the compression, based on my limited messing with it, suuuuuuuucks. Also the encoder in ffmpeg doesn't use threads at all.
I don't know if this is intentional allowing of it, but at least right now they're allowed to be posted. Watch this be fixed very soon.
Do me a favor and tag them autoplaying gif or autoplaying webp please. Right now they don't get a play button like gifs do.
anyway the ffmpeg command you want is
ffmpeg -i input.mp4 -c:v libwebp -lossless 0 -compression_level 6 -loop 0 -an output.webp
You can replace input.mp4 with whatever your input filename is. It can be any kind of video, or gif. Technically you can feed it a sequence of images too but that's some extra work. Ask me if you really need that.
You want libwebp instead of libwebp_anim, though I think these may actually be the same thing. If you just give ffmpeg an input file and output webp, it says it's using _anim but the output looks like crap.
Lossy settings instead of lossless don't seem to do much and the encoding quality goes down the tank really fast. webp is somehow worse than even VP8 (read: webm) by a big margin. Yuck. The compression level here is just how much encoding to do; you will always want this set to 6.
Loop is interesting, webps don't infinite loop by default. 0 will make it loop forever, default is 1 (no loop, only plays once), obviously if you want a specific loop count you could set this here.
-an is just to remove audio if it's present. Might not be needed.
Still here? Cool. So if you're on windows, assuming you've already installed ffmpeg and it's present in CMD's path, meaning you can just type ffmpeg.exe and it runs,
@echo off
%~d1
CD "%~p1"
FOR %%A in (%*) DO ffmpeg -i %%A -c:v libwebp -lossless 0 -compression_level 6 -loop 0 -an "%%~nA.webp"
If you put that into a batch file you should be able to drag and drop any gif or video file onto it and it will drop a converted webp next to it. I've not tested this at all and I don't know if ffmpeg installs to path by default on windows or not. Also, remember what I said about webp being super inefficient? Staying under 5MB will be difficult. You may want to try scaling that down to 50 or 75% of the original resolution, by adding -vf scale=in_w/2:in_h/2 for 50% size or -vf scale=in_w/1.5:in_h/1.5 for 75% size. I think / works in windows cmd, right...?
Once it's a little more well known and/or gets an autoplay button like gifs I might make this a more proper guide so people can upload here easier. I really do not like webp but it is, just barely, a better option than gif. But still worse than everything else.