How to compress audio files using ffmpeg

Whenever I go home and meet my friends after a long time, its like a tradition to share songs. Since, I keep my Music collection on the laptop, I don't have to deal with disk space issues. Where as the filesize of a song does matter to most of my friends, because they use iPods or MP3 players. For them, small size songs means more songs.

So, the solution to this problem was audio compression but I didn't know any application in linux that could compress songs. I was thinking of switching to Windows to do this task when I came across this great tool FFmpeg.

What is audio compression?

The whole concept behind audio compression is to lower the audio bitrate(128kbps, 192 kbps etc.). So, all we need to do is set the audio bitrate manually(ofcourse a value lower than the original) to compress an audio file. You might want to keep in mind that, a high bitrate audio file confirms a better sound quality so by lowering its bitrate, you are actually degrading the quality.

How to Compress audio files using FFmpeg

You can use the '-ab' flag to set the audio bitrate of a media file. Suppose you already have a song of 320kbps bitrate. And you want to compress it to 128kpbs. This is how you do it using FFmpeg.

[shredder12]$ ffmpeg -i inputfile.mp3 -ab 128 outputfile.mp3

This will result in a 128kbps outputfile.

This list might help you get a better understanding of the relation b/w audio bitrates and the corresponding sound quality. This list is the work of http://www.mp3-tech.org/tests/gb

  • 96kbs: The sound clearly lacks definition: as an example, hall's noises are perceived as some breath. The result is comparable to a good FM radio.
  • 112kbs: The sound seems less present and less natural than the original. The definition is a bit less good, the voice is less clear. Attacks are less spontaneous. The spatialization is different from the original recording: the sound seems to be located more far and more lower. There is however a very noticeable improvement compared to 96kbs.
  • 128kbs: Hall's noises are slightly less defined than the original. The violin is a bit less present and the piano attacks a bit less sharp. The voice is nearly identical to the original recording but sibilants are less pronounced. We can notice the same spatialization problem as with the 112kbs's one although there is again a good improvement compared to the 112kbs rate.
  • 160kbs: The sound is more natural than 128kbs but the improvement is less spectacular than during the two preceding stages. The sound is different from the original, without however being possible to tell in what. I think that the difference resides more in what we feel rather than in what we hear.
  • 192kbs: The sound is not felt as the original recording. It is however totally impossible to tell in what.
  • 256kbs: The sound is indiscernible from the original. It is impossible to make the difference with the original recording.
  • 320kbs: The sound is indiscernible from the original. It is impossible to make the difference with the original recording.
  • CD Audio : The sound of the burned CD is strictly identical the manufactured CD. This test, although it could appear useless, is however necessary so in order to insure that it is impossible that the burning step introduces differences, that would have falsified tests.

2 Comments

ffmpeg-windows-user (not verified)
September 18th, 2010 10:22 am
from the above example, ffmpeg -i inputfile.mp3 -ab 128 outputfile.mp3 but should use 128k ffmpeg -i inputfile.mp3 -ab 128k outputfile.mp3
Anon Linuxer (not verified)
November 26th, 2010 03:56 am
> I didn't know any application in linux that could compress songs IMHO you should search your distro's package manager - there is bound to be lots of apps you could use. For Ubuntu I prefer 'sound converter' which makes these conversions a piece of cake... ffmpeg for video coding, but not for audio....

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Use syntax $$latex$$ to insert LaTeX formulas.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.