How to convert .m4a audio files to .mp3 use command line?

How to convert .m4a audio files to .mp3 command line? (with no deterioration in quality, if possible). Ubuntu 16.04LTS media info:

General
Complete name                            : show.m4a
Format                                   : MPEG-4
Format profile                           : Apple audio with iTunes info
Codec ID                                 : M4A  (M4A /mp42/isom)
File size                                : 55.5 MiB
Duration                                 : 1h 48mn
Overall bit rate mode                    : Variable
Overall bit rate                         : 71.7 Kbps

Audio
ID                                       : 1
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : HE-AAC / LC
Codec ID                                 : 40
Duration                                 : 1h 48mn
Bit rate mode                            : Variable
Bit rate                                 : 72.0 Kbps
Maximum bit rate                         : 93.8 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz / 22.05 KHz
Frame rate                               : 21.533 fps (1024 spf)
Compression mode                         : Lossy
Stream size                              : 54.9 MiB (99%)
Writing library                          : Nero AAC codec 1.5.4.0
Encoding settings                        : -q 0.25

I note that your input file is actually a Variable Bitrate (VBR) AAC file with an overall bitrate of 71.7 Kbps and a maximum bitrate of 93.8 Kbps. So you actually have two reasonable choices: encode to a Variable Bitrate MP3 file or simply decide on a suitable bitrate for Constant Bitrate (CBR) MP3 encoding. And FFmpeg is certainly the best tool for both of these!

1. Variable Bitrate (VBR) Encoding

This would be my own choice if only for the reason that the original AAC file is also a VBR file. Encoding to MP3 with a variable bitrate of 70-105 Kbps can be mapped to FFmpeg with the -q:a 8 option as below:

ffmpeg -i show.m4a -c:a libmp3lame -q:a 8 output.mp3

And I suspect that this is your best option with your input file.

2. Constant Bitrate (CBR) Encoding

Constant Bitrate (CBR) Encoding is a little over-used IMHO but if this suits your playback equipment best then it is a valid choice. Since your input file has an overall bitrate of 71.7 Kbps and a maximum bitrate of 93.8 Kbps we could perhaps fudge the numbers a little and use the following:

ffmpeg -i show.m4a -c:a libmp3lame -b:a 96k output.mp3

Some experimentation might be in order with good choices for the bitrate being taken from the following LAME 'allowable' standards: 64k, 80k, 96k, 112k. Whatever sounds best on your playback hardware...

References:

  • FFmpeg MP3 Encoding Guide: FFmpeg Trac's great guide to encoding to mp3. Especially note the VBR mapping table marked 'LAME Bitrate Overview'.

Give this a try:

sudo apt-get install ffmpeg

This will install the ffmpeg package.

We can see what formats are acceptable by typing:

ffmpeg -formats 

Or

 ffmpeg -codecs

Navigate to the directory your audio files are in with the cd command. If you need help finding the directory use the ls command.

$ ls
backup.log         Desktop    examples.desktop  Music     snap
branches-tutorial  Documents  flick             Pictures  Templates
SumDocument        Downloads  mozilla.pdf       Public    Videos

Lets say my files are in the Desktop folder. I would then type:

cd Desktop

Now I will be in the correct directory. Following, now we type:

ffmpeg -i show.m4a newFileName.mp3

To convert with a specified bitrate ( In your case it looks like 71.1Kbps with a max of 93.8Kbps - I'm not sure what will happen if trying to use the max vs the Overall bit rate, unfortunately), we run:

ffmpeg -i show.m4a -b:a 71100 newFileName.mp3

I pulled this information from https://www.howtoforge.com/tutorial/ffmpeg-audio-conversion/

Please note that conversion to a lossless codec (mp3) inevitably will lead to (not necessarily audible) quality loss.


You can use FFmpeg command-line version.

ffmpeg -i inputfile.m4a -acodec libmp3lame -ab 93k outputfile.mp3

In the process of converting it to MP3, always there will be some quality loss(Although it may be unnoticeable to human hearing). MP3 is a lossy format (no matter the format of the original). You can read more about lossy and lossless formats here