Search code examples
ffmpegimage-compression

How to control mjpeg compression quality in ffmpeg?


Is there a way to define the "quality/amount" of compression in ffmpeg with the mjpeg codec? Like -crf can be used with videos.

i.e. (mjpeg codec)

ffmpeg -i input.jpg output.jpg

produces a well compressed image, although it is slightly too compressed, what parameters can be tweaked to perform less/"better" compression?

Is there a better tool or library than ffmpeg?


Solution

  • You could use ImageMagick like this:

    magick input.jpg -quality 82 result.jpg
    

    You can also control the chroma sub-sampling if you really want to. Check the actual quality with:

    magick identify -verbose image.jpg      # or, more specifically
    magick identify -format %Q  image.jpg