FFmpeg: Keeping quality during conversion
FFmpeg sets the -crf
option to 23 by default.
Try:
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"
Related videos on Youtube
x74x61
Updated on September 18, 2022Comments
-
x74x61 almost 2 years
Possible Duplicate:
Convert AVI to MP4 keeping the same qualityI'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
-
slhck over 11 yearsI just remembered that the same question was asked yesterday, converting AVI to MP4, keeping the quality.
-
-
x74x61 over 11 yearsThanks. 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 over 11 yearsOne more question though: What would you recommend for audio?
-
slhck over 11 years@x74x61
libvo_aacenc
is considered to deliver rather bad quality in comparison tolibfaac
, which has a default (variable bitrate) quality setting of 100% (-q:a 100
). Give that a try. -
Jānis Elmeris over 3 yearsWhat is the
strict
option there for? -
MRule almost 3 yearsI'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.