Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimized images with FFmpeg? [closed]

Google PageSpeed recommends the images on my web page could be optimized. The lossless compression would save an average of 11%, however my images are created with the following FFmpeg command:

ffmpeg -i '$video_path' -vcodec mjpeg -vframes 1 -an -f rawvideo -ss 00:00:20 -s 145*108 $thumb_image

Is there a way I can optimize these images?

like image 261
user1788377 Avatar asked Oct 31 '12 11:10

user1788377


1 Answers

First of all -s 145*108 is not a valid ffmpeg option; it should be -s 145x108. For proper scaling of your images see the answer to How to create thumbnail image from .flv video by using ffmpeg? for some examples that will keep your aspect ratio. You did not specify your image type, so I'll assume you are outputting to jpeg. You can change the output quality with -qscale:v (or -qscale if using old ffmpeg syntax). Range for jpeg is a linear scale of 1-31 where 1 is best quality and 31 is worst quality.

JPG

As for losslessly optimizing jpeg, you can use jpgcrush or jpegtran:

jpegtran -optimize -copy none -perfect -v input.jpg > output.jpg

I've noticed that Opera doesn't properly display images processed with jpgcrush but this was some time ago that I checked.

PNG

For png you have a variety of tools including pngcrush, optipng, and advpng among several others:

optipng -o7 input.png

Remember that FFmpeg usage questions are better suited for superuser.

like image 99
llogan Avatar answered Sep 21 '22 08:09

llogan