Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

marked as duplicate by slhck Dec 30 '12 at 13:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

1 Answer 1

up vote 3 down vote accepted

FFmpeg sets the -crf option to 23 by default.

Try:

ffmpeg.exe -i "test.avi" -c:v libx264 -crf 20 -c:a libvo_aacenc "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 libvo_aacenc -ss 60 -t 60 "test.mp4"
share|improve this answer
    
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 '12 at 12:13
    
One more question though: What would you recommend for audio? –  x74x61 Dec 30 '12 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 '12 at 13:10

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