So i have been generating preview animations in GIF formats using FFMPEG. (basically selecting a few seconds of the whole video and storing as gif)

however the previews that youtube generates in webp format seem way more smaller in size than what i have achieved.

Here is the command i use to generate a 3 second preview in webp format:

ffmpeg -i d:\1.mp4 -lossless 0 -ss 00:00:00 -t 00:00:03 -s 320x180 1.webp

But this is still larger than equivalent gif.

Any tips on how to reduce the output webp animation?


even with max compression and min quality ffmpeg it still produces much larger webp outputs than what gif2web gives.

  • Is this issue resolved for you?
    – Hassaan
    Sep 23, 2019 at 19:38

2 Answers 2


decrease quality http://ffmpeg.org/ffmpeg-codecs.html#libwebp

-quality float
 For lossy encoding, this controls image quality. 
 For lossless encoding, this controls the effort and time spent in compression. 
 Range is 0 to 100. Default is 75.

fix qscale to quality.

  • Please use -q:a or -q:v, -qscale is ambiguous
    – Matt
    Jan 7, 2021 at 2:53

These are reasonable compression settings for an animated thumbnail.

-compression_level 6 -q:v 75

-loop 0 if you want it to loop. Compression level ange is 0 to 6. Quality range is 0 to 100. https://developers.google.com/speed/webp/docs/cwebp

If you're willing to spend more time decoding, you can make more interesting thumbnails by taking short scenes from the whole video. Check out my gist.

#Creates an animated thumbnail of a video clip
#This script uses scene cuts instead of fixed time intervals, and does not work well for videos with few/infrequent scene cuts

numOfScenes=8 #max number of scenes
sceneLength=1.5 #length of each scene in seconds
sceneDelay=1.7 #time (seconds) after a frame cut to start scene (to avoid transition effects)

for i;do
  meta=($(ffprobe -v 0 -select_streams V:0 -show_entries stream=r_frame_rate:format=duration -of default=nw=1:nk=1 "$i"))
  framerate=$(bc <<< "scale=3;${meta[0]}/2")
  sceneSpacer=$(bc <<< "scale=3;${meta[1]}/(($numOfScenes-1)*2)") #min time between scene selection

  ffmpeg -nostdin -ss $sceneSpacer -i "$i" -vsync vfr -vf "select=if(gt(scene\,0.5)*(isnan(prev_selected_t)+gte(t-prev_selected_t\,$sceneSpacer))\,st(1\,t)*0*st(2\,ld(2)+1)\,if(ld(1)*lte(ld(2)\,$numOfScenes)\,between(t\,ld(1)+$sceneDelay\,ld(1)+$sceneDelay+$sceneLength))),scale=320:180:force_original_aspect_ratio=decrease:force_divisible_by=2:flags=bicubic:sws_dither=none,framestep=2,setpts=N/($framerate*TB)" -an -sn -map_chapters -1 -map_metadata -1 -hide_banner -compression_level 5 -q:v 75 -loop 0 -f webp -y "${i%.*}".webp
  • What is the default compression level if you don't specify one? Feb 10, 2022 at 22:39
  • Default compression level is 4.
    – Voldrix
    Mar 8, 2022 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .