FFMPEG – How to Get the Smallest Video with Same Quality

ffmpeg

I know its a "lame" question, but: lets say, I have a wmv, avi, etc BIG file. I want to convert it to .MP4, with the possible smallest file size, and of course with the same quality with audio/video. How to? What codec should I use? Im using FFmpeg

Best Answer

You can try to encode with libx264 CRF 18. The CRF parameter sets the quality and influences the file size. Lower values mean higher quality, and typical values are from 18 to 28. The default is 23.

CRF 18 is well known for producing a (arguably) "visually lossless" result:

ffmpeg -i input.avi -c:v libx264 -crf 18 -preset veryslow -c:a copy out.mp4

Notice that I used a veryslow preset which will give you the smallest file possible. You can leave it out if you want to encode faster, but the file size will be larger, too.

Also, I decided to copy the audio track instead of reencoding it (-c:a copy), mainly because I assume it's already AAC/MP3 stereo in your sample.

If the output is too big for you, try with a higher CRF value (up to 23) but the quality will suffer.

Related Question