ffmpegbmp

How to specify size of output image in FFmpeg command?


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?


Solution

  • 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