Many times it has happened to me that I have X video clip whose song is attractive to me, however I do not have the audio file of that song (.mp3, .ogg, etc.). The solution is simple: «download the .mp3 or CD from the internet), but this in addition to being something illegal, ... is in my opinion a bad waste of bandwidth, because if I already have the audio in the video, why what not to get the audio out of the video? 🙂
To do this we have several alternatives, in this article I will show you how to do it with just 1 command 😀
First we must have installed mplayer, if you don't have it installed you must install it 😉
En Debian, Ubuntu, SolusOS, Mint, etc ... would be:
sudo apt-get install mplayer
pacman -S mplayer
And well, the idea is understood right? 😀
Now suppose the video file is: basshunter_saturday.mkv
We open a terminal in the folder where the file is, and we put:
mplayer -vo null -dumpaudio -dumpfile archivo.mp3 basshunter_saturday.mkv
That is:
mplayer -vo null -dumpaudio -dumpfile archivo-de-audio-final.mp3 el-video.loquesea
In my case a file called file.mp3 right next to the video:
It has personally helped me many times.
Now… is there no way to do this graphically using an application? … Yes, of course, but that's another post 😀
regards
This is exactly the only thing that RealPlayer Converter was missing!
Thank you, thank you, thank you, I use it mostly to extract audio from YouTube videos. For evil purposes.
A pleasure to help 😀
I use http://www.youtube-mp3.org/
That page is cool. I have to try it. Until now I used ffmpeg. I love seeing how many different ways there are to do each thing. 🙂
Using a graphical application I always use Avidemux. It is a workhorse.
With SoundKonverter (Qt) and SoundConverter (GTK) you can too.
Interesting, although in my case I use firefox addons for it, or the mobile media converter.
I actually use MMC for many things https://blog.desdelinux.net/mobile-media-converter-excelente-aplicacion-para-convertir-videos/
but ... I am lazy to have to open it for something so simple, I open a terminal right there in the file browser, and that's it 😀
I kill the end of the post, ha.
Very good, I did not know that you could do that with mplayer, I always use ffmpeg.
Thanks for the information.
Thanks, I did not know that function in Mplayer as well….
A pleasure to help ... and, mplayer is a genius, you can do everything with him haha.
It did not work for me with a couple of flv videos = (
try with: ffmpeg -i tuvideo.mp4 -vn -acodec copy audio.m4a
You can use m4a or aac as audio output, videos in flv (in your case) or mp4 normally use the h264 codec for video and the aac codec for audio (those of youtube).
I think I am missing as a note in the article, that you can only copy or "extract" the audio in the format it is, if you want in the crappy .mp3, it would be to copy / extract the audio and then convert.
I missed adding, if you want to know the codec that uses the video / audio (speaking of the terminal) you can do it with ffprobe (part of ffmpeg)
ffprobe yourvideo.mp4
After it shows you what codec it uses for the audio, you apply the command and output of the corresponding audio.
it can also be done with mediainfo (tugestordepaquentes install mediainfo)
or from VLC with Ctrl + J or Menpu Tools - Codec information
Excellent your comments 😀
What error did it give you? … I have tried it with MKV, RMVB and other rare formats and it worked for me 🙁
Open those videos with VLC, and see if it indicates that the index of the video is corrupt.
Or easier:
ffmpeg -i video-file audio.mp3 (or whatever audio format you want)
I had not tried this one, I'll keep an eye on it lol
Thank you
Good tip, in fact I was seeing that with certain parameters the track can be extracted very, very quickly (I already did the test).
For example if we say ffmpeg -i file-video.flv
The streams that the video contains should be output as a result, and if then we notice that the audio is encoded in mp3, for example, we could do something like this:
ffmpeg -i archivo-video.flv -vn -sn -acodec copy audio.mp3
In this way we are telling it not to process the video streams and subtitles, and to copy the audio stream as is, without recoding so that quality is not lost.
How flexible is free software, right?
Dumpfile only dumps the audio of the video in the format it was encoded in.
You can check the true audio codec with ffmpeg as follows:
ffmpeg -i multimedia-file.ext 2> & 1 | grep -E '(Duration) | (Stream)'
If the audio codec is mp3 if you can convert it to mp3, let's see what the command would look like
ffmpeg -i basshunter_saturday.mkv 2> & 1 | grep -E mp3 && mplayer -vo null -dumpaudio -dumpfile file.mp3 basshunter_saturday.mkv
Note: it seems to me that the video formats that use the mp3 codec are the divx (.avi).
If the video codec is not mp3 we will use these methods:
1- With lame (only if it supports the codec):
lame -r "basshunter_saturday.mkv" "output-file.mp3"
2- Extracting the video codec to wav and encoding:
mplayer -vo null -vc dump -ao pcm: file = »file.wav» video.ext && lame -r «file.wav» «file.mp3» && rm «file.wav»
A tutoring with Kdenlive and Avidemux is coming 😛
It does not work, it does not extract aac type file, a file (data) appears that it has to be converted later.
When you fall and fall to the same place to lift a tip, a tip, a help, a fishing rod, it is that on the other side there is a great community work, impossible not to drop a simple thank you pin.
Thank you desdelinux!
I did not try it because I found another option with VLC but my respects kzkg gara, you have very good contributions (Y) one day I will be Hokage XD lol but really my respects
Thank you very much mate!
With cclive (http://linuxgnublog.org/descargar-videos-de-youtube-en-gnulinux/) to download videos from Youtube and the solution that you propose I have the perfect tools to download and extract the sound.
A abrazo.
To extract Mp3 from Youtube this website: http://www.youtomp3.net/
This great, totally free with a single click.
http://www.youtomp3.net/
Is there a command that gives me a kind of demultiplexer? in other words, it extracts everything without converting anything. MP4 OGV H.264, MP2 AAC AC3 MP3, SRT SUB,
with mp4 it takes longer? mkv there nomas extracts the audio
I had to use another online method to convert mp4 to ac3 https://convertio.co/es/mp4-ac3/