139

Is there an application that allows me to extract the audio from a MP4 or FLV video file and store it as an MP3 file for use in a portable media player?

5
  • 1
    technically you can't, but what you can do is extract the sound from the video into MP3 format...
    – TheXed
    Oct 2, 2012 at 17:35
  • 2
    Both mp4 and flv video files contain aac audio. To have that audio as mp3 is easy, but there may be some problems converting between lossy formats. The input and output bit-rates have to be considered. See the discussions in the different answers under this question. Maybe the best solution would be to keep the audio in aac format, that is in the m4a container - more here
    – user47206
    Aug 30, 2013 at 9:40
  • 2
    @cipricus Both mp4 and flv video files can contain sound in many formats including aac and mp3. For example the FLV container specification mentions no less than 15 types of supported sound codecs/types.
    – octavn
    Oct 26, 2015 at 15:25
  • @OctavianNaicu - You are right. My comment was intended at promoting the idea of keeping the audio without conversion. That is a good idea no matter the format, but of course one should know beforehand what the specific audio format is there, by using a tool like mediainfo. (On the other hand, as flv and mp4 are the common formats of youtube videos, which contain AAC audio, I had imagined the question was implicitly referring to youtube.)
    – user47206
    Oct 28, 2015 at 9:01
  • I agree with you that the audio should not be converted if possible. I was trying to convey the idea that containers can hold audio data in different formats and you need to look at the format/codec not at the container. Depending on the source audio format one might need to transcode the audio (for example aac in mp4 to mp3 in mp3) OR just copy it over to the new container (mp3 in mp4 to mp3 in mp3).
    – octavn
    Oct 28, 2015 at 12:06

11 Answers 11

157
+50

You can do the same in 12.04 by using several software.

Using WinFF

  1. Install winff and libavcodec-extra first

     sudo apt-get install winff libavcodec-extra
    
  2. Open Winff from dash

    enter image description here

  3. Then in Winff window, do these

    1. Add file

    2. Select what catagory to convert (select Audio)

    3. Select Audio file format (mp3)

    4. Type the output folder for converted file

    enter image description here

    1. Then click the Convert button. You can also click Options button to file tune the audio format and other options.

    enter image description here

    enter image description here

Using VLC

  1. Install VLC and "libavcodec-extra" package first

    sudo apt-get install vlc libavcodec-extra
    
  2. Open VLC from dash by pressing Super key and typing "VLC" there

    enter image description here

  3. Then from top panel menu, Select MediaConvert/Save.

    enter image description here

  4. Then Add file to convert in the new window. Then click Convert button.

    enter image description here

  5. In the new window, Select the directory for output file, select the conversion profile (Audio mp3) and click Start button.

    enter image description here

Using command line

  1. First install the tools

    sudo apt-get install ffmpeg libavcodec-extra libav-tools
    

    If you are using

  2. Use this simple command to extract the audio file

    avconv -i /input-file-name-with-path output-filename.mp3
    

    For example to convert the "How fast.ogg" video file into how-fast.mp3 use this command:

    avconv -i /usr/share/example-content/Ubuntu_Free_Culture_Showcase/How\ fast.ogg how-fast.mp3
    

    See the manual page for more options and information.

To Just extract audio

Check these answer

12
  • 1
    I think in the command line the libavcodec-extra-53 package is important. Before I installed it, I do not succeded to convert to mp3. Oct 22, 2012 at 16:50
  • 1
    @ArpaD wasn't that i said in the answer?
    – Anwar
    Oct 22, 2012 at 16:51
  • 2
    Outstanding answer. Nice work.
    – kevinarpe
    Jan 6, 2014 at 13:11
  • 4
    Now I think it's 56. But why not just install the libavcodec-extra metapackage? Jun 7, 2015 at 7:56
  • 3
    +1 for avconv. I've been looking for a simple command-line way to do this for a long time! Jan 3, 2017 at 8:28
68

you can do it using ffmpeg. Install ffmpeg using following command:

sudo apt-get install ffmpeg libavcodec-unstripped-52

The package libavcodec-unstripped-52 is available in Multiverse repo, so you will need to enable it.
After installing these packages, you can use a command like the one below to extract the audio as mp3:

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

The -i option in the above command is simple: it is the path to the input file. The second option -f mp3 tells ffmpeg that the ouput is in mp3 format. The third option i.e -ab 192000 tells ffmpeg that we want the output to be encoded at 192Kbps and -vn tells ffmpeg that we dont want video. The last param is the name of the output file.

7
  • 1
    I did some more searching on ffmpeg, I found this wonderful guide catswhocode.com/blog/19-ffmpeg-commands-for-all-needs
    – b-ak
    Nov 20, 2011 at 8:33
  • 3
    I prefer the newer audio/video converter avconv. syntax is similar to ffmpeg: 'avconv -i input.mp4 -vn -qscale 1 output.mp3' ... -qscale 1 ensures maximum quality (and VBR) and the type of the encoder is deduced from the output file extension.
    – arielf
    Jul 8, 2012 at 4:07
  • ffmpeg now comes from libav-tools. Nov 29, 2013 at 16:56
  • 1
    Running this program, it says: *** THIS PROGRAM IS DEPRECATED *** This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    – melmi
    Dec 12, 2013 at 16:52
  • Nice answer, because ffmpeg can be used on mac os, and I don't need to switch to ubuntu :)
    – kelin
    May 9, 2016 at 21:18
13

soundconverter is another tool that can convert audio formats and also video to audio only:

Install via the software center

or via the terminal:

sudo apt-get install soundconverter

1
  • I had to do sudo apt-get install ubuntu-restricted-extras to enable conversion to mp3s May 31, 2016 at 4:19
9

It is very easy to do with WinFF (install it), which is a GUI for ffmpeg.

  1. Click add.
  2. Select a video file
  3. In Convert to, select Audio
  4. Select an audio codec
  5. Click Convert. (Notice that the Convert button might sometimes disappear if the window is too small. Make the window larger if you don't see it)

Done. Screenshot:

enter image description here

6

Audacity can also open a flv file and export it as mp3, flac and other formats

enter image description here

enter image description here


My favorite way is to use gnome-terminal -e "avconv -i %f %f.mp3" in Thunar custom actions. Even better, to get a constant bitrate of 192 kbps:

avconv -i %f -c:a libmp3lame -ac 2 -b:a 190k %f.mp3

In fact the audio in a flv (and mp4) file is in aac format. To stay as close as possible to the quality of the original sound, consider using the aac in an m4a container. If the mp3 format is a must, consider the initial bitrate of the aac file when converting to mp3. More here.

5

soundconverter Install soundconverter is another tool that can convert audio formats and also video to audio only.

It can be installed in the Software Center (by clicking the above link) or by running these commands in a Terminal (Ctrl+Alt+T):

sudo apt-get update
sudo apt-get install soundconverter
2
  • have you tested converting flv to mp3 in soundconverter? while converting mp4 video to mp3 works ok, in my case it works endlessly with no result to a flv file that winff converts in seconds
    – user47206
    Feb 1, 2013 at 11:58
  • also install ubuntu-restricted-extras for mp3 conversion May 31, 2016 at 4:20
3

You can convert your media files using VLC player. Load a media file => to convert: Menubar > Media > Convert/Save.

1
  • Thanks for the tip. I have been using VLC for a while but I didn't know of this feature
    – Mysterio
    May 11, 2012 at 17:57
3

You can achieve this with a simple command:
ffmpeg -i yourVideoInput.mp4 theAudioOutput.mp3

1
  • cant find aconv in latest ubuntu, ffmpeg works as above
    – teknopaul
    Sep 23, 2023 at 23:38
1

mkvtoolnix is a good package, it can extract by tracks, chapters or specific timings at the same time.

mkvmerge -i <input_video>

Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (AC-3/E-AC-3)
Track ID 2: audio (AC-3/E-AC-3)

You want to extract TrackID 2 by each chapters (assume the long video)

mkvmerge -o <output_audio> --audio-tracks 2 --no-video --split chapters:all <input_video>  

You get numbered files, output_audio001, output_audio002...

Then convert each audio file to mp3

0

Transmageddon

You can also use Transmagedon Video Converter to convert video file to sound file.

Install via the software center

Or in trminal:

sudo apt-get install transmageddon

To convert to MP4, you have to select in Choose Video Codec as No Video.

Can convert to .ogg by selecting the Presets as Ogg.

enter image description here

0

I used VLC media player to convert a .flv file to a .mp4/mp3 file. Audacity failed at even loading the complete file. It could load only the first 8 seconds and I could export the audio. But, VLC was the fastest! Let every other piece of software be!

You must log in to answer this question.

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