9

Kindly let me know if there is any method to compress image using FFMPEG

ffmpeg -i img.png imgOut.png

How to compress the output image or change the quality if it

Guillaume Jacquenot
  • 11,217
  • 6
  • 43
  • 49
Alharith Aqra'
  • 99
  • 1
  • 2
  • 6

2 Answers2

19

PNG

Just use the default settings. PNG is lossless so there is no way to control the quality, but you can control the compression. You can use -compression_level for PNG output if you want less compression. Range is 0-100. Default is 100 which is most compression meaning that the defaults provide the smallest output file size.

Output a series of PNG images from a video. Files will be named output_0001.png, output_0002.png, output_0003.png, etc.

ffmpeg -i input.mp4 output_%04d.png

Output a single PNG image from a video at around 00:02:00.

ffmpeg -ss 00:02:00 -i input.mp4 -frames:v 1 output.png

If you want additional processing refer to pngcrush, optipng, advpng, etc.

JPEG

For JPG output see How can I extract a good quality JPEG image with ffmpeg?

llogan
  • 121,796
  • 28
  • 232
  • 243
-2

PNG is a lossless image format, so you can't really toggle the compression ratio in any useful way. Typical options such as -b:v only apply to formats to which ratecontrol applies (e.g. most video codecs, or .jpg for images).

Ronald S. Bultje
  • 10,828
  • 26
  • 47