Possible Duplicate:
Convert AVI to MP4 keeping the same quality

I'd like to convert a good amount of wmv, mpg and avi files (with differing audio and video encodings) to mp4/x264/aac with equivalent quality. I've done some tests with the following command:

ffmpeg.exe -i "test.avi" -c:v libx264 -c:a libvo_aacenc "test.mp4"

(As you can see, I've omitted options that specify the bitrate and quality of audio and video)

Using this command, FFmpeg automatically preserves the video dimensions, but I'm still not sure how it handles things like bitrate when they are omitted? What is the best way to keep the quality of a video while converting it to a different format and codec?

I'm using 64 bit Windows 7 and ffmpeg-20121230-git-518239c-win64-shared

  • I just remembered that the same question was asked yesterday, converting AVI to MP4, keeping the quality.
    – slhck
    Dec 30, 2012 at 13:12

1 Answer 1


FFmpeg sets the -crf option to 23 by default.


ffmpeg.exe -i "test.avi" -c:v libx264 -crf 20 -c:a aac -strict -2 "test.mp4"

The CRF option sets the encode quality. The bit-rate will vary as necessary to provide a consistent quality throughout the video. 51 being the worst to 0 being the best — lossless.

I tend to set all my encodes to 20 which happens to be Handbrake’s default and I’ve been happy with the quality. I suggest playing around with that value to find a level of quality that is acceptable to you.

You might want to use the -ss and -t options to create short test encodes. -ss being the start time and -t being the duration — both in seconds. You probably don’t need to encode the entire video to determine what’s acceptable.

To create a 1min clip starting 1min into the video:

ffmpeg.exe -i "test.avi" -c:v libx264 -crf 20  -c:a aac -strict -2 -ss 60 -t 60 "test.mp4"
  • 1
    Thanks. I did some searching. According to this article, 23 is default, while 18 is considered visually lossless: "it should look the same or nearly the same as the input but it isn't technically lossless".
    – x74x61
    Dec 30, 2012 at 12:13
  • One more question though: What would you recommend for audio?
    – x74x61
    Dec 30, 2012 at 12:40
  • @x74x61 libvo_aacenc is considered to deliver rather bad quality in comparison to libfaac, which has a default (variable bitrate) quality setting of 100% (-q:a 100). Give that a try.
    – slhck
    Dec 30, 2012 at 13:10
  • 1
    What is the strict option there for? Jan 6, 2021 at 10:33
  • I've tried this, but get the error Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (output1.avi) has not been used for any stream.; evidently there are some pitfalls here. No clue why this happens or how to change it.
    – MRule
    Sep 16, 2021 at 12:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.