Advertisement

ffmpeg compression mp3

top computer
I success with this command
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
ffmpeg -i input_file.mp3 -ab 128k  output_file.mp3
ffmpeg -i inputfile.mp3 -acodec libmp3lame -b:a 8k -ac 1 -ar 11025 outputfile.mp3
-b:a = audio bitrate
-ar = sample rate
-ac channels = set number of audio channels
  • ffmpeg -i "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-RFTYZgBNprg.mp3" -acodec libmp3lame -b:a 112k -ac 2 -ar 44100 "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-112k.mp3"
  • ffmpeg -i "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-RFTYZgBNprg.mp3" -ab 112k "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-112k2.mp3"
  • ffmpeg -i "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-RFTYZgBNprg.mp3" -b:a 112k -ac 2 -ar 44100 "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-112k3.mp3"
explain:

FFmpeg MP3 Encoding Guide

This 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 other codecs you could use, and FFmpeg AAC Encoding Guide if you want AAC instead, and the official documentation.

VBR Encoding

Example to encode VBR MP3 audio with ffmpeg using the libmp3lame library:
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
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.
LAME Bitrate Overview
lame optionAverage kbit/sBitrate range kbit/sffmpeg option
-b 320320320 CBR (non VBR) example-b:a 320k (NB this is 32KB/s, or its max)
-V 0245220-260-q:a 0 (NB this is VBR from 22 to 26 KB/s)
-V 1225190-250-q:a 1
-V 2190170-210-q:a 2
-V 3175150-195-q:a 3
-V 4165140-185-q:a 4
-V 5130120-150-q:a 5
-V 6115100-130-q:a 6
-V 710080-120-q:a 7
-V 88570-105-q:a 8
-V 96545-85-q:a 9
In 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.

CBR Encoding

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 use -b:a 320k (but see note below).
Note: Using -b:a 320k is generally considered wasteful because:
  • -q:a 0 – -q:a 3 will normally produce transparent results.
  • MP3 is lossy anyway, so if you really want the highest quality use a lossless format such as FLAC.
See Hydrogen Audio: Recommended LAME Encoder Settings for more info.

ABR Encoding

ABR is something of a mixture between VBR and CBR, see the official documentation for details on use.

Troubleshooting

Sometimes the output will consist of fewer bits per second than requested:
  • With CBR it could be due to the chosen value being in-between allowable settings (it defaults down to the next lower acceptable bitrate).
  • 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.
  • Or possibly that the input was CBR, and the VBR aspect is able to reduce bitrate by a considerable amount.

Also see