FFmpeg command to convert to DivX
Solution 1
Either use a higher bit rate and/or use two-pass encoding, or use -qscale
to target a quality level in a variable bit rate mode, rather than a specific bit rate. See this blog post for slightly more in-depth information.
Qscale
The qscale range for mpeg4
is 1–31, where lower=better quality/higher filesize, and 3–6 can normally be considered a useful range. This will target a given quality, with a variable bit rate. You can similarly use qscale with libmp3lame, where the range is 0–9, with lower numbers giving better quality. See here for a bit more information; anything up to 6 will get you good quality.
Up-to-date syntax:
ffmpeg -i input.file -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 output.avi
Old syntax:
ffmpeg -i input.file -vcodec mpeg4 -qscale 5 -vtag DIVX -s 640x480 -acodec libmp3lame -aq 5 -ac 2 -ar 44100 output.avi
Two-pass encoding
Note that Windows users need to use NUL
rather than /dev/null
. Use this if you want to target a specific size, otherwise just use the VBR quality-targeting -qscale
option. These examples will fit a 90-minute movie onto a 700 MB CD-ROM.
Up-to-date syntax:
ffmpeg -y -i input.file -c:v mpeg4 -b:v 868k -tag:v DIVX -s 640x480 -an -pass 1 -f rawvideo /dev/null
ffmpeg -i input.file -c:v mpeg4 -b:v 868k -tag:v DIVX -s 640x480 -c:a libmp3lame -b:a 192k -ac 2 -ar 44100 -pass 2 output.avi
Old syntax:
ffmpeg -y -i input.file -vcodec mpeg4 -b 868k -vtag DIVX -s 640x480 -an -pass 1 -f rawvideo /dev/null
ffmpeg -i input.file -vcodec mpeg4 -b 868k -vtag DIVX -s 640x480 -acodec libmp3lame -ab 192k -ac 2 -ar 44100 -pass 2 output.avi
Note that you don't strictly need -ac 2
, since MP3 only supports two channels, so any surround-sound audio will automatically get mixed down.
You should consider using H.264 video/AAC audio in an MP4 container; the only reason to use DivX/MP3 in an AVI is if you need support on legacy hardware players. Using DivX results in worse quality compared to H.264-encoded video at the same bit rate.
Solution 2
You can try to specify a bigger value for the option -b 345k
. This determine the bit rate of the output video. Maybe, you can try to change -r fps
if needed.
You have to be careful when changing these value. Not all values are accepted for all codecs. Look at the help/manual of ffmpeg for more information.
Related videos on Youtube
![Gaff](https://i.stack.imgur.com/jg7xd.jpg?s=256&g=1)
Gaff
Updated on September 18, 2022Comments
-
Gaff almost 2 years
I'm trying to use ffmpeg to convert video to DivX. Here is my current command line:
-vtag DIVX -f avi -vcodec msmpeg4 -s 640x480 -b 345k -acodec libmp3lame -ab 256 -ac 2 -ar 48000
The problem with this is that I am getting a low quality DivX file when I want a high quality file. Can anyone point me to a better command for higher quality that would be helpful and is msmpeg4 the latest DivX codec?
-
slhck over 11 yearsCan you explain what the difference is or why this would work?