29

Original Question

Is there some cli tool to convert aac files from the iTunes Store (no DRM) to mp3?

Update 1

MP3 to MP3

I installed libavcodec-unstripped-52 and get a little further.

When I try to encode MP3 files with it: It says [mp3 @ 0x997cde0]Header missing.

lame also had problems since the tags are ID3v2, is it possible that the libmp3lame does not support that either?

Should I convert the tags or what can I do to get this working?

AAC to MP3

This went through, but there are no headers in the resulting MP3 file. How can I get the headers in there?

Martin Ueding
  • 8,218
  • 11
  • 52
  • 83

2 Answers2

39

The most appropriate command line tool is the ffmpeg utility available to be installed via the software center/synaptic manager.

A command line example would be something like this for Constant Bitrate Mode (CBR):

ffmpeg -i inputfile.m4a -c:a libmp3lame -ac 2 -b:a 190k outputfile.mp3

Or even better for Variable Bitrate Mode (VBR):

ffmpeg -i inputfile.m4a -c:a libmp3lame -ac 2 -q:a 2 outputfile.mp3

More information on mp3 encoding with FFmpeg can be seen here:

FFmpeg MP3 Encoding Guide

andrew.46
  • 37,085
  • 25
  • 149
  • 228
fossfreedom
  • 171,546
  • 47
  • 376
  • 404
  • 1
    okay, that looks very good. My ffmpeg just says "Unknown encoder 'mp3'". I have lame installed. – Martin Ueding Apr 16 '11 at 14:53
  • solved it by installing libavcodec-unstripped-52, but now I got the next problem. (I added it to the original question.) – Martin Ueding Apr 16 '11 at 15:15
  • have a look in synaptic - have you libfaad2 installed? Generally I use sudo apt-get install ubuntu-restricted-extras to ensure all relevant codecs are installed – fossfreedom Apr 16 '11 at 15:42
  • libfaad2 is installed, but I got by the mp3 with with libavcodec-unstripped-52 I believe. – Martin Ueding Apr 16 '11 at 15:51
  • 2
    I'm on natty - this is how I converted a downloaded aac file sudo apt-get install libavcodec-extra-52 followed by ffmpeg -i inputfile.m4a -acodec libmp3lame -ac 2 -ab 160 outputfile.mp3 – fossfreedom Apr 16 '11 at 18:32
  • Maverick here, but I got it with the same line. Thanks! – Martin Ueding Apr 16 '11 at 19:43
  • Maybe one more comment, it should actually be `-ab 160k` and not `-ab 160`. The `-ab` parameter takes bits, not kilobits. – Malte Skoruppa Jul 11 '14 at 00:36
8

If your Linux complain that he doesn't have an mp3 codec, try this:

ffmpeg -i inputfile.m4a -acodec libmp3lame -ac 2 -ab 160k outputfile.mp3

Note that the -ab parameters takes in bits per second, not kilobits per second.

Henry
  • 342
  • 1
  • 11
maxmurd
  • 81
  • 1
  • 1