Categories: Creative

How to make video size smaller with FFmpeg

If you want to make your video file that bit smaller whilst retaining its quality here is how with FFmpeg. Be aware that compressing video uses a lot of CPU. The more cores and speed (Ghz) of your CPU the better.

The two factors with FFmpeg that will best determine your output size is the -preset and -crf

Preset is the encoding to compression rate, The slower = better compression and therefor more quality in a smaller size. The slowest FFmpeg -preset is veryslow followed by slower and then slow.

CRF means constant rate factor, essentially it is the bitrate amount without it being specific. Lower value = higher quality. 0 is lossless but a value of 17 or 18 is still visually lossless. 21 or 22 i find to be best but once you start going above 25 the quality drops away.

To put it into one command something like this will take time but give a really good compress:

ffmpeg -i inputfilename.mp4 -c:v libx264 -preset veryslow -crf 21 outputfilename.mp4

Or for something a little quicker:

ffmpeg -i inputfilename.mp4 -c:v libx264 -preset slower -crf 22 outputfilename.mp4

To maximise your FFmpeg usage look into getting a dedicated server, You will be able to run these multi core tasks faster.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago