user4571931
user4571931

Reputation:

How to convert High bitrate MP3 to lower rate using FFmpeg

We want to convert 320kbps mp3 file to 128kbps mp3 so currently we are using below ffmpeg command but its not working.

ffmpeg -i input.mp3 -codec:a libmp3lame -qscale:a 5 output.mp3

Result:-the output bitrate same as input mp3.

And we are following the FFmpeg Encoding guideline for that here is the link :- https://trac.ffmpeg.org/wiki/Encode/MP3

so please suggest any solution.

Upvotes: 31

Views: 45672

Answers (4)

Alex
Alex

Reputation: 1011

Ubuntu 22:

$ ffmpeg -v debug -i "input.file" -c:libmp3lame -b:a 32k \
             -ac 1 -ar 44100 -vn "out.file"

However Ubuntu 18 gives an error, so the working command:

$ ffmpeg    -i rassel.mp3     \
             -codec:a libmp3lame    -b:a 32k  \
              -ar 44100    -ac 1     rassel-out.mp3

Upvotes: 1

Benji
Benji

Reputation: 380

Make sure your version of FFmpeg has libmp3lame enabled. The selected answer didn't work for me, but this did:

ffmpeg -v debug -i "input.mp3" -c:a libmp3lame \
   -b:a 128k -ac 2 -ar 44100 -vn "output.mp3"

-ac 2 - output has 2 (stereo) audio channels -ar 44100 - sample rate of 44100Hz, which is ideal for high quality music.

Although, in 2022 I wouldn't recommend converting to 128kbps since storage space is much more cheap and abundant nowadays.

I think -b:a 192k strikes the best balance between compression and quality for most people (unless you're an audiophile with $1000 headphones, and even then you'd be better off using FLAC anyways).

Upvotes: 6

coderofsalvation
coderofsalvation

Reputation: 1803

I use this shellscript in order to not visit this stackoverflow-page over and over again :)

#!/bin/bash
[[ ! -n $1 ]] && { 
    echo "Usage: mp3convert <input.mp3> <output.mp3> <bitrate:56/96/128/256> <channels> <samplerate>"
    exit 0
}
set -x # print next command
ffmpeg -i "$1" -codec:a libmp3lame -b:a "$3"k -ac "$4" -ar $5 "$2"

Upvotes: 9

VC.One
VC.One

Reputation: 15881

I tried your shown command (tested on Windows / commandline) :

ffmpeg -i input.mp3 -codec:a libmp3lame -qscale:a 5 output.mp3

Result : It works for me. However the -qscale:a 5 makes FFmpeg decide on an average bitrate for you. With one (320k) MP3 file I got it giving a close convert of 134kbps. This is expected since :

lame option   Average kbit/s  Bitrate range kbit/s    ffmpeg option
   -V 5             130           120-150                -q:a 5

Solution :
Instead of making the internal mp3 frames hold different bitrates (that vary to acommodate the "current" perceived audio, eg: think "silent" parts using smaller rate of bits/bytes compared to "busy" audio parts), so just set a constant bitrate of 128kbps as you need.

I would just set it to constant 128kbps manually and explicitly with :

ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 128k output.mp3

Upvotes: 39

Related Questions