WebP image format was introduced by Google in 2010 and it’s is based on lossy and lossless intra-frame coding of the VP8. 

Google claims WebP images using lossless compressed are 26% smaller in file size compared to PNGs, and files with lossy compression are 25-34% smaller in size compared to JPEG images at equivalent perceived quality.

WebP format is opened by almost all browsers – Firefox, Microsoft Edge, etc. 

 

How to Encode Images in WebP Format?

First of all check that your whether  ffmpeg supports WebP image format encoding or not:

ffmpeg -codecs | findstr libwebp 

 DEVILS webp                 WebP (encoders: libwebp_anim libwebp )

If no then i recommend to take full ffmpeg binaries for Windows

Alternatively you can configure ffmpeg sources with  ‘–enable-libwebp’ and compile it.

 

Note:

  • ffmpeg libwebp only supports YUV420 for lossy
  • Compression quality is controlled by ‘-compression_level’, the range 0-6, where 0 is best quality (low compression ratio) and 6 is the worst quality (high compression ratio)
  • if you know ahead a type of image you can configure corresponding preset (‘-preset’):

‘none’ –  don’t use preset

‘default’  – general type of image

‘picture’  –  digital picture, like portrait

‘photo’   outdoor photograph, with natural lighting

‘drawing’  hand or line drawing, with high-contrast details

‘icon’ small-sized colorful images

‘text’  – documents

Example: 

Encode the first frame (‘ -frames 1’) of yuv-sequence in WebP Image format:

 

ffmpeg -s 1920×1080 -i crowdrun1080p50fps.yuv -c:v libwebp -frames 1 -compression_level 6  -y  test.webp 

compression ratio relationship for crowdrun1080p sequence

 compression_level    compression ratio
6 9
5 8.7
3,4 8.3
2,1 7.7
0 7.4

 

Example:

Re-encode png-file in lossless mode to WebP image format: 

ffmpeg -i flashes.png -c:v libwebp -lossless 1  -y  flashes.webp

compression ratio ~3:1

 

Example with known picture type (outdoor photo)

ffmpeg -s 1920×1080 -i crowdrun1080p50fps.yuv -c:v libwebp -frames 1 -compression_level 4 -preset photo -y test.webp  

 

How to Encode Sequences in WebP Format?

To encode for example the first 50 frames of input sequence crowdrun1080p50fps.yuv  use ‘-c:v libwebp_anim

 

ffmpeg -s 1920×1080 -i crowdrun1080p50fps.yuv -c:v libwebp_anim  -frames 50 -compression_level 4 -preset photo -y test50.webp

 

Notes:

ffplay cant’ play WebP animation format, although most of browsers play

ffmpeg is not configured to provide correct frame rate for WebP animation, it sets 25fps.

21 Responses

  1. Can I simply say what a reduction to seek out somebody who really knows what theyre talking about on the internet. You definitely know methods to convey an issue to light and make it important. Extra individuals need to read this and understand this side of the story. I cant consider youre no more popular since you positively have the gift.

  2. Awsome post and right to the point. I am not sure if this is really the best place to ask but do you guys have any ideea where to get some professional writers? Thx 🙂

  3. I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back later. Many thanks

  4. Its like you read my mind! You appear to grasp a lot approximately this, like you wrote the e book in it or something. I think that you can do with some to force the message home a bit, however instead of that, that is fantastic blog. An excellent read. I will certainly be back.

Leave a Reply

Your email address will not be published. Required fields are marked *