Changes between Version 11 and Version 12 of Encode/MP3


Ignore:
Timestamp:
Jun 5, 2014, 2:34:13 AM (5 years ago)
Author:
llogan
Comment:

general formatting and cleanup

Legend:

Unmodified
Added
Removed
Modified
  • Encode/MP3

    v11 v12  
    1 = FFmpeg mp3 =
     1= FFmpeg MP3 Encoding Guide =
    22
    3 This page describes how to use the "lame" encoder within ffmpeg to creates mp3's (ffmpeg apparently has no native mp3 encoder).  See also [[GuidelinesHighQualityAudio|other codecs]] you could use, and/or [[AACEncodingGuide]] for background on FFmpeg audio encoding in general.
     3This page describes how to use the external libmp3lame encoding library within `ffmpeg` to create MP3 audio files (`ffmpeg` has no native MP3 encoder).  See also [[GuidelinesHighQualityAudio|other codecs]] you could use, and [[Encode/AAC|FFmpeg AAC Encoding Guide]] for background on FFmpeg audio encoding in general.
    44
    55= VBR Encoding =
    66
    7 Example to encode VBR MP3 audio with `ffmpeg` using the `libmp3lame` library:
     7Example to encode VBR MP3 audio with `ffmpeg` using the libmp3lame library:
    88{{{
    99ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
    1010}}}
    1111
    12 Control quality with `-qscale:a` (or the alias `-q:a`). Values are encoder specific, so for `libmp3lame` the range is 0-9 where a lower value is a higher quality. 0-3 will normally produce transparent results, 4 (default) should be close to perceptual transparency, and 6 produces an "acceptable" quality. The option `-qscale:a` is mapped to the `-V` option in the standalone `lame` command-line interface tool.
     12Control quality with `-qscale:a` (or the alias `-q:a`). Values are encoder specific, so for libmp3lame the range is 0-9 where a lower value is a higher quality. 0-3 will normally produce transparent results, 4 (default) should be close to perceptual transparency, and 6 produces an "acceptable" quality. The option `-qscale:a` is mapped to the `-V` option in the standalone `lame` command-line interface tool.
    1313
    1414||||||= '''LAME Bitrate Overview''' =||
    15 || Option || Kbit/s || Bitrate range kbit/s || ffmpeg equiv.
    16 || -b 320 || 320 || 320 CBR (non VBR) example || -b:a 320k (NB this is 32KB/s, or its max)
    17 || -V 0 || 245 || 220...260 || -q:a 0 (NB this is VBR from 22 to 26 KB/s...)
    18 || -V 1 || 225 || 190...250 || -q:a 1
    19 || -V 2 || 190 || 170...210 || -q:a 2
    20 || -V 3 || 175 || 150...195 || -q:a 3
    21 || -V 4 || 165 || 140...185 || -q:a 4
    22 || -V 5 || 130 || 120...150 || -q:a 5
    23 || -V 6 || 115 || 100...130 || -q:a 6
    24 || -V 7 || 100 || 80...120 || -q:a 7
    25 || -V 8 || 85 || 70...105 || -q:a 8
    26 || -V 9 || 65 || 45...85 || -q:a 9
     15|| `lame` option || Kbit/s || Bitrate range kbit/s || `ffmpeg` option
     16|| `-b 320` || 320 || 320 CBR (non VBR) example || `-b:a 320k` (NB this is 32KB/s, or its max)
     17|| `-V 0` || 245 || 220-260 || `-q:a 0` (NB this is VBR from 22 to 26 KB/s)
     18|| `-V 1` || 225 || 190-250 || `-q:a 1`
     19|| `-V 2` || 190 || 170-210 || `-q:a 2`
     20|| `-V 3` || 175 || 150-195 || `-q:a 3`
     21|| `-V 4` || 165 || 140-185 || `-q:a 4`
     22|| `-V 5` || 130 || 120-150 || `-q:a 5`
     23|| `-V 6` || 115 || 100-130 || `-q:a 6`
     24|| `-V 7` || 100 || 80-120 || `-q:a 7`
     25|| `-V 8` || 85 || 70-105 || `-q:a 8`
     26|| `-V 9` || 65 || 45-85 || `-q:a 9`
    2727
    2828In our example above, we selected `-qscale:a 2`, meaning we used LAME's option `-V 2`, which gives us a VBR MP3 audio stream with an average stereo bitrate of 170-210 kBit/s.
     
    3030= CBR Encoding =
    3131
    32 If you need constant bitrate (CBR) MP3 audio, you need to use the `-b:a` option instead of `-qscale:a`. Here you can specify the number of bits per second, for example `-b:a 256k` if you want 256 Kbit/s (25.6 KB/s) audio.  Available options are: 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320 (add a k after each to get that rate).  So to get the highest quality setting, it would be like `-b:a 320k`.
     32If you need constant bitrate (CBR) MP3 audio, you need to use the `-b:a` option instead of `-qscale:a`. Here you can specify the number of bits per second, for example `-b:a 256k` if you want 256 Kbit/s (25.6 KB/s) audio.  Available options are: 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320 (add a `k` after each to get that rate).  So to get the highest quality setting use `-b:a 320k` (but see note below).
     33
     34{{{
     35#!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;"
     36
     37'''Note:''' Using `-b:a 320k` is generally considered wasteful because:
     38
     39* `-q:a 0` – `-q:a 3` will normally produce transparent results.
     40* MP3 is lossy anyway, so if you really want the highest quality use a lossless format such as FLAC.
     41
     42See [http://wiki.hydrogenaudio.org/index.php?title=LAME#Recommended_encoder_settings Hydrogen Audio: Recommended LAME Encoder Settings] for more info.
     43}}}
    3344
    3445== Troubleshooting ==
    3546
    36 Sometimes it will give you *less* bits per second than you request.  If you're doing CBR, it could be because you chose a value "in between" its allowable settings (if defaults down to the next lower).  If you're doing VBR, it could be because the input itself is already in a lower bitrate than the requested, in which case, it basically just re-encodes it at the bitrate the input already was.  Or possibly that the input was CBR and the VBR aspect is able to reduce bitrate by quite a lot.
     47Sometimes the output will consist of fewer bits per second than requested:
    3748
     49* With CBR it could be due to the chosen value being in-between allowable settings (it defaults down to the next lower acceptable bitrate).
     50* With VBR it could be due to the input already in being a lower bitrate than requested, in which case, it basically just re-encodes it at the bitrate of the input.
     51* Or possibly that the input was CBR, and the VBR aspect is able to reduce bitrate by a measurable amount.
     52
     53{{{#!comment
     54Is anything in this section confirmed or just anecdotal evidence?
     55}}}
    3856
    3957== Also see ==