After upscaling an old movie, I wanted to compress the output to make it a more appropriate size.
Control Quality
Quality is controlled through specifying a bitrate through -b:v and -b:a
Most popular is the constant rate factor resulting in variable bit rate in a single pass.
Range | 0 – 51 |
Sane Range | 19 – 26 |
18 | “high quality” |
28 | “low quality” |
ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4
Constrain the profile
Profiles define a feature set the encode may use. baseline
, main
or high
ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline output.mp4
Choose an x264 encoding preset
The presets affect the encoding speed.
ultrafast
, superfast
, veryfast
, faster
, fast
, medium
(default) , slow
and veryslow
ffmpeg -i input.mp4 -c:v libx264 -preset slow output.mp4
Final Example
Following the excellent writeup from user slhck on superuser.com the command I used to re-encode my video
ffmpeg -i "input.mp4" -c:v libx264 -profile:v main -preset veryfast -crf 24 "output.mp4"