55

I have some songs which are in mp4 format and I want to convert them into mp3 format.

I am new to Ubuntu/Linux. So please explain the step by step process or give any software which can do the above job.

2
  • 1
    @GrSr - Judging from the context, I believe srinu is asking about MP4 audio files (typically M4A extension).
    – reverendj1
    Aug 10, 2012 at 15:02
  • @reverendj1 yeah but look at the answers provided .
    – Raja G
    Aug 10, 2012 at 15:08

8 Answers 8

59

I would recommend Sound Converter. It is extremely simple to use for what you want. You can find it in the Software Center, or install it from the terminal:

sudo apt-get install soundconverter

Ubuntu Repo: soundconverter
Apt Link: Install soundconverter

All you need to do is open it up, change your preferences (Edit -> Preferences) then click the "Add File" or "Add Folder" buttons to add the music to be converted, and click Convert. It doesn't get much simpler.

6
  • 2
    Thanks, I tried transcoding some large .mp4 files from youtube into CBR MP3 files and I love how soundconverter utilized all four of my CPU cores out of the box.
    – alexg
    Apr 19, 2014 at 6:41
  • On a relatively fresh install of Ubuntu 15.10, this crashes almost every time I hit the convert button. Shame, seemed like a good program otherwise. Mar 3, 2016 at 8:25
  • perfect for mp4->mp3 conversion Apr 15, 2016 at 18:07
  • 1
    To enable conversion from mp4 to mp3 in ubuntu 16, I had to do sudo apt-get install ubuntu-restricted-extras May 31, 2016 at 4:19
  • ubuntu 17. no mp3 converter!
    – Nurlan
    Aug 29, 2017 at 14:52
39

I have extracted the audio from mp4 and m4a files and converted them to mp3 format many times; it is very useful when a lot of podcasts come in m4a or mp4 format.

I found that the most reliable way to allow ffmpeg to use proprietary formats was to build it from source, although you can see if it works with jfreak53's method if you do not wish to build from source. (After uninstalling any ffmpeg files, I compiled ffmpeg from source using this guide)

In addition, the following script, which I have modified, (credit to the original creator), preserves the original name of the file in the newly converted file, which may be useful for you. Save it in a text editor and make it executable with chmod +x yourscriptname.

#!/bin/bash
for f in *.mp4
do
    name=`echo "$f" | sed -e "s/.mp4$//g"`
    ffmpeg -i "$f" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "$name.mp3"
done

In addition, following a suggestion by evilsoup, you could also use the following one-liner. It 'converts every MP4 in the current directory to an MP3', preserves the original name of the file, and 'to use it for an flv or avi or whatever, simply change both instances of mp4':

for f in *.mp4; do ffmpeg -i "$f" -vn -c:a libmp3lame -ar 44100 -ac 2 -ab 192k "${f/%mp4/mp3}"; done
3
  • @evilsoup I've incorporated your suggestion.
    – user76204
    Dec 6, 2012 at 0:24
  • 1
    Ubuntu does not ship ffmpeg so you can install libav's avconv. Just install package libav-tools with apt-get and use avconv instead of ffmpeg Works great, thanks! Sep 10, 2014 at 17:07
  • The -ab option does not exist, according to the documentation. Additionally, it’s not necessary to change the bitrate and especially not the sampling rate, nor to specify a codec, so the following line is completely sufficient (and the shell replacement part a bit more safe): for x in *.mp4; do ffmpeg -i "$x" -vn -f mp3 ./"${x%.mp4}.mp3"; done — the ./ before the output filename is especially needed for videos from youtube-dl whose names can begin with a hyphen-minus and thus will cause errors with the other command lines.
    – mirabilos
    Oct 19, 2016 at 15:54
19

If you mean export the audio from the video MP4 file then use ffmpeg, I do this all the time from FLV files. Firstly install ffmpeg:

sudo apt-get install ffmpeg libavcodec-unstripped-52

The run:

ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3

It might say that your missing some codecs for MP4, in that case just run:

aptitude search codecname

And find it to install.

By the way, you can get more information about this by searching the web. Here are a few useful resources, found in this way:

1
  • Does this re-encode the audio, thus reducing quality? Or is there a way to do this losslessly? Edit: Nevermind, found out how and posted an answer below. Jan 25, 2014 at 20:46
7

Here's how to extract the audio from an MP4 video losslessly (keeping the original sound intact without reducing quality)

ffmpeg -i video.mp4 -vn -acodec copy audio.m4a

Granted, this results in an M4A audio file not MP3. But most software and cell phones now can play M4A out of the box.

1
  • You can't stream those though (ssh server cat file.m4a | mplayer - errors out). I found out that you can stream them using the right container format, at no quality loss either: for x in *.mp4; do ffmpeg -i "$x" -vn -sn -c:a copy ./"${x%.mp4}.wma"; done (see my comment above for why the ./). Do note that the original question did ask about conversion to MP3, which does include re-encoding and, thus, loss of quality.
    – mirabilos
    Oct 19, 2016 at 16:50
1

http://www.iasptk.com/ff-multi-converter-is-a-simple-graphical-application-which-enables-you-to-convert-audio-video-image-and-document-files-between-all-popular-formats

FF Multi Converter is a simple graphical application which enables you to convert audio, video, image and document files between all popular formats, using and combining other programs. It uses ffmpeg for audio/video files, unoconv for document files and PythonMagick library for image file conversions.

The goal of FF Multi Converter is to gather all multimedia types in one application and provide conversions for them easily through a user-friendly interface. Extra options will be gradually added.

The application is written in python and PyQt.

All code is licensed under the GNU General Public License.

FF Multi Converter is free software - software that respects your freedom.

Features

Conversions for several file formats.

Very easy to use interface.

Access to common conversion options.

Options for saving and naming files.

Recursive conversions.

Installing on Ubuntu and Debian

Stable release

To add the ppa to your system resources and install ffmulticonverter, open a terminal and enter:

sudo add-apt-repository ppa:ffmulticonverter/stable

sudo apt-get update

sudo apt-get install ffmulticonverter

Development release

Just change ppa name to ppa:ffmulticonverter/unstable and type the same commands as above.

1

I would recommend Winff a GUI for ffmpeg for all video/audio conversions.
All you do is add the video, choose your output (audio, mp3) in this case, choose the folder the converted file is to be saved in and click convert.

sudo apt-get install winff

0

Whether you mean video or audio, Audacity works great (it can extract audio from any supported video file). I use it now. I used to use ffmpeg, but it was a little complicated and some formats weren't available/didn't work.

1
  • Wait, I meant Winff, a GUI frontend for ffmpeg.
    – Wegko
    Aug 10, 2012 at 15:34
-1

Combining things here, but this keeps file names and dumps a original sound copy to m4a:

for f in *.mp4; do name=`echo "$f" | sed -e "s/.mp4$//g"` && ffmpeg -i "$f" -vn -acodec copy "$name.m4a"; done

Not the answer you're looking for? Browse other questions tagged .