Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify size of output image in ffmpeg command?

Tags:

ffmpeg

bmp

I'm extracting frame images from an MP4 video using ffmpeg in terminal.

I used the command:

ffmpeg -i Video.MP4 Pictures%d.bmp

Problem is that the extracted images have a size of 4.5-5MB! I want smaller images, say around 1-2 MB. How do I limit the size of output images?

like image 244
saladguy Avatar asked Dec 07 '22 06:12

saladguy


2 Answers

The file size is a function of your video resolution and of the output format you choose. For example:

width x height x 3 bytes ( RGB24)

You have different ways to reduce the output file size.

  1. Change the format for example YUV 4:2:0 with -pix_fmt yuv420 and I think the smaller format you can choose is gray or yuv400 but check with the following command showing the ffmpeg supported pixel format

    ‘ffmpeg -pix_fmts

the BMP format should handle that (generate a 8bpp image) but confirm with the file size that you get a factor 3!

  1. Change the output resolution (HD to SD or CIF) with -s <Width>x<Height>, e.g.:

    ffmpeg -i Video.MP4 -s 192x168 Pictures%d.bmp
    

    or with the -vf option:

    ffmpeg -I Video.MP4 -vf scale=192:168 Pictures%d.bmp
    
like image 185
alexbuisson Avatar answered Dec 28 '22 10:12

alexbuisson


there is one more option you have to reduce filesize of the output pictures : Use another picture format like *.jpg.

ffmpeg -i input.flv -ss 00:00:14.435 -f image2 -vframes 1 out.jpg

(Source : http://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video)

Have a nice day ;)

like image 29
CCfVssZijV2X Avatar answered Dec 28 '22 09:12

CCfVssZijV2X