You should first upgrade to at least FFmpeg 0.9. vpre
is not really encouraged to be used for preset control anymore. This is why the ffpreset
files have been removed from newer versions. Preset control for libx264 now happens through x264 itself, not through FFmpeg.
That being said, setting an average bitrate for x264 is the worst rate control mode there is. Rather than an average bitrate, you should consider using two-pass encoding if you are targeting a specific output file size, or setting a Constant Rate Factor (CRF) if you just care about achieving a specific quality. If in doubt, use CRF.
You generally want the following syntax for using FFmpeg and x264:
ffmpeg -i in.mp4 -vcodec libx264 <options> out.mp4
… with the following non-mandatory options. It is important to specify them before the output and after the vcodec
switch. Those are just some (see also the options mapping for more):
-vprofile
: Set h.264 profile constraints, e.g. baseline
, main
, high
-preset
: Set an encoding preset, which generally enables optimization strategies. You can choose from veryslow
, slow
, fast
, ultrafast
, and many more. Slower presets result in better compression at a cost of slower encoding. You generally use the slowest preset you have patience for.
-tune
: Set a special tune factor, e.g. for movies: film
-b
: Set the bitrate. As already said, this is not really what you want with a one-pass encoding, but if you need to, this should work. Possible values are in Bits, or rather 500K
, 1M
, et cetera.
-crf
: Set quality. Mutually exclusive with -b
. A good starting value is 24. A lower value is higher quality. Use the highest value that still looks good to you.
Two-pass example, H.264 video, AAC audio in MP4:
ffmpeg -i input -c:v libx264 -preset slow -b:v 500k -pass 1 -an -f mp4 -y NUL
ffmpeg -i input -c:v libx264 -preset slow -b:v 500k -pass 2 -c:a libfaac -b:a 128k output.mp4
CRF example, H.264 video, MP3 audio in MKV:
ffmpeg -i input -c:v libx264 -preset medium -crf 24 -c:a libmp3lame -q:a 4 output.mkv
Best Answer
...will convert any file with audio into a Constant Bit Rate MP3 @ 96 kbit/s. Music files normally store cover images as a video stream, which will be stripped by this command; M4A files do this differently, but ffmpeg is currently not able to access that data, so it will be stripped whatever you do. This will also select the first audio stream, if there are multiple audio streams.
CBR mode should be faster than VBR, and using a low bit rate should be faster than a higher one.
Of course, file size can be easily calculated from the bit rate. A one-minute CBR MP3 @96 kbit/s will have a file size of
60s*96000bit/s=5760000 bit, /8192=703.125 KB
.