Getting the smallest video with same quality, how to with 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

1

3 Answers

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.

2

Getting the smallest video with the least amount of quality lost is more of a challenge than anything else. There are guides scattered among the Web that will recommend you settings to use on FFmpeg for things like game captures, streams, DVD rips, etc.

If you want lossless lossless, try this:

ffmpeg -i input.mp4 -c:v libx264 -crf 0 output.mp4

The important part is the -crf 0 part which sets it to lossless. However, the output file will generally be very large. You could change it to -crf 18 which would give you something that is acceptable in quality and free from most artifacts.

2

2021

H265 / HEVC version :

ffmpeg -i input.mp4 -vcodec libx265 -crf 18 -tag:v hvc1 -preset veryslow -an output.mp4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like