How to Extract Audio From Video in Ubuntu and Other Linux Distributions
In a recent article you saw the best ways to download YouTube videos in Ubuntu. In a similar post, you’ll see how to extract audio from a video file in Ubuntu and other Linux distributions.
There are several tools you can use to for this. Converting video to MP3 or other audio format is a simple task in Linux.
I’ll show you three methods in this tutorial:
Method 1: Extract audio from video using VLC Media Player
If you use Linux as a daily driver, you’re quite likely to have VLC Media Player installed.
VLC can do a lot of things other than playing videos. You can download subtitles, synchronize subtitles and what not. One of the cool VLC tips is to convert videos to audio.
Click on Convert/Save in the Media drop down menu or use the ctrl + R shortcut.
Click on the Add button and select the desired video file, then choose the Convert/Save button to proceed to the next step.
Video Audio 13
Here, choose the desired audio format by selecting the appropriate Profile option.
Set the destination for the extracted audio to be saved and as the default format for saving converted videos is .mp4, make sure the file extension matches the selected profile.
Click Start to start the extraction.
Method 2: Using “4K Video to MP3” tool [Not open source]
Since the source code for this tool is not available and it is only available as a .deb file, it can only be installed on Debian/Ubuntu or Linux distributions based off them like Elementary OS, Zorin OS, KDE Neon, Linux Mint and MX Linux.
4K Video to MP3 is only available for 64 bit systems, so if you’re not sure, you should check whether your system is 32 bit or 64 bit.
Once downloaded, double click on it to install. For faster installation, I would recommend to use gdebi as your default installer instead of Ubuntu Software Center.
Once, 4K Video to MP3 is successfully installed, launch 4K Video to MP3 from the application menu.
When you select the Add Video option, the audio is extracted and the audio file is saved in a preconfigured location (
/Music/4K\ Video\ to\ MP3/). If you want to save it in a custom location, first click the Preferences option.
Video Audio 02 1
In Preferences, you can choose the desired audio format, quality and destination folder.
Video Audio 03
Once you’ve set the required settings, click on the Add Video button, choose the source video and wait for the conversion to complete.
Method 3: Extract audio from video using ffmpeg command line tool
Almost anything can be done on the terminal and most of the time, it requires just one command. In this case, ffmpeg can be used, which is a command line tool which can extract audio fromo the desired video with just one command.
To extract audio from an input video file using ffmpeg, use:
Replace and with the corresponding paths along with appropriate file extensions.
There are a lot of other options to extract audio from a video file in Linux, including Sound Converter, which is fairly simple to use and is available for all Linux Distributions as its tarball can be downloaded.
If you want to experiment with audio-video further, I suggest to read on how to record streaming audio in Ubuntu. You can also read about recording Skype calls in Ubuntu.
I hope you find this tutorial helpful. Stay tuned for more such articles. If you have questions or suggestions, feel free to leave a comment.
Like what you read? Please share it with others.
Using ffmpeg to extract audio from MP4 media file on Linux
Futhermore, the following linux command will extract audio from foo.mp4 and convert it to ogg Vorbis audio. For example: Alternatively, ffmpeg also allows to adjust the audio output sampling rate to eg. 44100, 22050,11025 . The following linux command will change to output audio sampling rate to 22050 Hz: MP3: OGG:
You may also be interested in:
Newsletter
Subscribe to Linux Career Newsletter to receive latest news, jobs, career advice and featured configuration tutorials.
Write For Us
LinuxConfig is looking for a technical writer(s) geared towards GNU/Linux and FLOSS technologies. Your articles will feature various GNU/Linux configuration tutorials and FLOSS technologies used in combination with GNU/Linux operating system.
When writing your articles you will be expected to be able to keep up with a technological advancement regarding the above mentioned technical area of expertise. You will work independently and be able to produce at minimum 2 technical articles a month.
How can I convert audio from MP4 or FLV video files to mp3?
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?
11 Answers 11
You can do the same in 12.04 by using several software.
Using WinFF
Install winff and libavcodec-extra first
Open Winff from dash
Then in Winff window, do these
Select what catagory to convert (select Audio)
Select Audio file format (mp3)
Type the output folder for converted file
- Then click the Convert button. You can also click Options button to file tune the audio format and other options.
Using VLC
Install VLC and «libavcodec-extra» package first
Open VLC from dash by pressing Super key and typing «VLC» there
Then from top panel menu, Select Media → Convert/Save.
Then Add file to convert in the new window. Then click Convert button.
In the new window, Select the directory for output file, select the conversion profile (Audio mp3) and click Start button.
Using command line
First install the tools
Use this simple command to extract the audio file
For example to convert the «How fast.ogg» video file into how-fast.mp3 use this command:
See the manual page for more options and information.
To Just extract audio
Check these answer
you can do it using ffmpeg. Install ffmpeg using following command:
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:
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.
Extract audio from video in Linux with a GUI program?
When I use Thunar I like adding to custom actions command lines like those presented here, here and here to extract audio from videos. I mean without transcoding/altering the sound, just putting it out of the video (a flv or mp4 video, for example, is a aac audio — which cannot be played as such, but rapped into a m4a, like in the the command in the links posted. a webm video has a ogg audio which needs to be extracted.)
Now, I am using elementayOS, and will not use Thunar, nor Nautilus, just Pantheon-Files.
I want to know if there is a GUI solution to achieve this.
4 Answers 4
Command line
If you’re willing to forgo using a GUI you can use ffmpeg fairly easily to do this.
Sample file
If you go to QuickTime: Sample files, you can download this sample file, sample_mpeg4.mp4. After downloading it, unzip it.
Example
You can extract the AAC audio frpm the mP4 file.
The resulting AAC file.
You can also use ffmpeg to confirm the file format:
You can use VLC and it’s Convert/Stream feature to do this. After launching VLC.
Example
Select Convert/Save from File pulldown
Select video file, and convert stream
Start the conversion
Better than trying to add context menu commands to the minimalist Pantheon-Files of Elementary OS or to use other media applications to extract sound from video, I guess the most simple is just to install Nautilus (it is not at all problematic in eOS, contrary to Thunar, which comes with the whole Xfce environment).
I will provide an example for extracting audio (aac in m4a container) from flv and mp4 video files.
Define a new action, give it a name, maybe an icon too. Check — ‘Display action in selection context menu’.
Under the command tab, add the command
bash -c ‘ffmpeg -i «$0» -map 0:1 -c:a copy «$<0%%.*>«.m4a’ %f .
Under Execution tab there are options to select depending on what you want to see during and after the action (open terminal, report).
Under Mimetypes tab, enter the filters for the type of files in the context menu of which you want to see the command — in this case: video/mp4 and video/flv .
There are other options, but these look sufficient for the purpose of my question.
Similar actions can be added to extract sound from other types of video and, of course, for other very different purposes.
(This solution is based on suggestions and solutions present in the links already posted in the question and the credit goes to the authors.)