How To Resize, Reduce a Video to a Specific Size and Quality Ubuntu Linux using ffmpeg

This is a common issue when e-mailing or uploading video files.

One note is that you should make the filesize you choose below about 20% smaller than you need.  For example I took a 219MB video and told it to be 20M.  The resulting file was still about 21.9M but it was OK when I said 18M and was barely below the 20M size.

ffmpeg is our friend here, just use this command:

  1. Change the -fs 100M to the size you want eg. 20M, 500M
  2. Change the -i TheLargeVideo.mp4 to the name of your video
  3. Change the TheLargeVideo-resize.mp4

ffmpeg -i TheLargeVideo.mp4 -fs 100M TheLargeVideo-resize.mp4

Sometimes it doesn't work

Sometimes what you tell it to do is impossible, for example on a 652MB file that was about 4:55 in length.  The above command made it 15MB as we specified -fs 15M, but the problem is that it only had 22 seconds of video.  In other words ffmpeg will try to do something impossible and stops at the filesize you specify, even if some of the video gets chopped off! It doesn't explicitly error out, so be sure to make sure the time of the output/smaller video is the same as the original.

We told it to do something that was impossible with the codec and default quality settings.

Ideal Solution

You could also try setting a different, more efficient codec like x264 with -vcodec x264 and use crf with a higher value, even though the default is usually CRF 28.

CRF's highest value is 51 and results in a very blocky/pixelated video.

ffmpeg -i TheLargeVideo.mp4 -crf 35 -fs 100M -vcodec libx265 TheLargeVideo-resize.mp4

If you have a newer computer/version if you can try libx265 which looks better and may produce a small filesize.  If not then use libx264

If CRF 35 was a bit too small, you could try going for 32


Extreme Solution

If it still doesn't work out above, you will have to increase the -crf value which results in lower quality and also a lower filesize. 

What did fix it was setting -crf to a high value (40), which results in much lower quality, you could also try 35-38 to see if it still meets the target size, as the quality will be better too.

ffmpeg -i TheLargeVideo.mp4 -fs 100M -crf 40 -vcodec libx265 TheLargeVideo-resize.mp4


resize, reduce, ubuntu, linux, ffmpegthis, mailing, uploading, filesize, mb, resulting, ok, ffmpeg, fs, eg, thelargevideo, mp,

Latest Articles

  • CentOS 7 / 8 cannot boot with with mdadm RAID array solution
  • How To Add Default Gateway in Linux using the ip route command routing
  • Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist Solution for Centos8 yum package install error
  • md mdadm array inactive how to start and activate the RAID array
  • Loaded: masked (Reason: Unit hostapd.service is masked.) Solution in Linux Debian Mint Ubuntu
  • Linux Mint Ubuntu Ubiquity Installer Bug EFI Installed To Wrong Partition Solution
  • Libreoffice Impress How To Change The Color of Links
  • ecryptfs How To Backup / Migrate Linux Mint Ubuntu Debian system ecryptfs properly and restore access
  • i915 nouveau Nvidia GPU not starting lightdm Xorg failing solution for Could not determine valid watermarks for inherited state
  • br0: received packet on bond0 with own address as source address Linux Solution Mint Debian Redhat CentOS bridge bridging
  • Debian Mint Ubuntu Howto Disable Network Manager
  • AMD GPU Xorg Won't Start [3576284.324] (EE) Segmentation fault at address 0x0 [3576284.325] (EE) Fatal server error: [3576284.325] (EE) Caught signal 11 (Segmentation fault). Server aborting
  • symbol 'grub_calloc' not found grub boot error solution / fix
  • /var/log/journal huge/too large solution in Debian Mint Ubuntu Linux Howot Fix
  • Libreoffice Calc Opens CSV Spreadsheet File as Asian Language/Chinese Characters Solution Fix
  • RTL8821AU Setup Configure Wifi Realtek 8821 in Linux Debian Mint Ubuntu Howto
  • How To Tell Which Repository a Package Comes From Debian Mint Ubuntu
  • How To Reload All Kernel Modules And List Required Moduels for Each Device - Linux Mint Debian Ubuntu Troubleshooting
  • Debian Ubuntu Mint How To Change Default Display Manager
  • Ubuntu Mint Debian Howto Execute Command / Script / Program Upon Wakeup From Sleep