extract audio from video or online stream

March 1st, 2007 mysurface Posted in ffmpeg, Misc, mplayer | Hits: 223415 | 36 Comments »

You can easily extract audio from video files such as avi, mpg, even flv! into mp3 uses either mplayer or ffmpeg. You can even record online stream into mp3, such as stream from radio cast.

Lets begin with mplayer. To extract audio from video files, use -dumpaudio option and specified the output filename with -dumpfile

mplayer -dumpaudio nodame_theme.flv -dumpfile nodame_theme.mp3

Okay check out the output:

file nodame_theme.mp3

Output:

MPEG ADTS, layer III, v2,   8 kBits, 22.05 kHz, Monaural

Okay, The audio extracted from flv, so quality is quite low, haha. But you can change the audio rate by using ffmpeg. Let see how to use ffmpeg.

ffmpeg -i nodame_theme.flv -ab 128 -ar 44100 nodame_theme.mp3

-i is to specified input file, -ab audio bitrate, -ar audio sampling frequency

Let say what file tells you.

MPEG ADTS, layer II, v1, 128 kBits, 44.1 kHz, Monaural

How about record online stream?
First, find an online radio cast to try, you can have plenty of it from shoutcast.

mplayer -dumpstream http://64.236.34.97:80/stream/1005 -dumpfile smoothjazz.mp3
ffmpeg -i http://64.236.34.97:80/stream/1005 -ab 128 -ar 44100 smoothjazz.mp3

Thanks to Mohd Shakir, you can make it a script for stream recording.

36 Responses to “extract audio from video or online stream”

  1. [...] Another ways to watch the videos is ripping out, there are many cases where you wanna extract out certain tracks from dvd or vcd and watch it later. You can do it with mplayer, as simple as you can extract audio from online stream or video files. [...]

  2. The ffmpeg step to increase the mp3′s bitrate and sampling rate is a waste of time and space. It won’t increase the sound quality at all. In fact, it may slightly degrade sound quality if the mp3 encoder throws out different parts of the audio the second time it’s compressed. And the resulting file will take up far more space than the original when you’re through.

    It’s like recording a phone conversation in a recording studio. You’re limited by the quality of your source.

  3. AndrewTam Says:

    ur just stupid johnboy id recommend u shut up b4 making a fool of urself

  4. Well, no, Johnboy is perfectly correct. You can’t get better quality than the source material. Increasing the bitrate just uses more space, but there isn’t any more audio data available to put in that space than there was in the original. And since mp3 is lossy, any additional encoding step will degrade it somewhat.

  5. Johnboy is right. You won’t get any better sound than the one you have in the original file… how could you?

  6. You’re a complete idiot. Johnboy is definitely right, how do you think ffmpeg should “increase quality”? Getting the missing information from nowhere?

    Please check what you write before someone poorly educated in information theory gets fooled by your pathethic advices.

  7. Hey, look at my modified bash script at http://www.donneker.de/projects/radio_rip – its easy to use with streamtuner and you can hear and record the stream you need with one connection and so save bandwith too. just have a try and gimme feedback!

  8. I say:

    garbage in,…….garbage out!

  9. [...] extract audio from video or online stream » Linux by Examples (tags: linux audio mp3 video howto extract tutorial mplayer flash flv convert multimedia opensource ffmpeg mencoder) [...]

  10. You could also extract audio from a videofile with avidemux

  11. Mister Mogi Says:

    you… extract… audio… vlc also :-)

  12. [...] Linux by Example audio [...]

  13. I see many people tried to go to my website to probably see the script, but the link here is outdated. The new link is at:
    http://www.mohdshakir.net/2007/02/27/shell-script-for-the-day-listen-to-online-radio-offline

    Thanks

  14. [...] mplayer -dumpaudio Metallica.avi -dumpfile Metallica.mp3 [1] [1] http://linux.byexamples.com/archives/229/extract-audio-from-video-or-online-stream/ [...]

  15. These people are right, encoding it again won’t help it at all.

  16. These people are right, encoding it again won’t help it at all.

  17. Thank you so much. It will be useful tip for me.

  18. [...] [...]

  19. [...] (thanks to here) [...]

  20. He/she never said that it would increase the quality ;), just that it would increase the bitrate.

  21. A little late, but w.e

    I’m assuming that mplayer doesn’t let you set the bitrate and saves it with a crappy default 8kb (as there is no way an op would be recorded with such bad quality), but ffmpeg does. So (s)he redoes it from the _original_ file (not the mplayer rip) with a higher quality. (S)he is a linux user, can’t assume (s)he is dumb.

    Or… i could be wrong.

  22. anon from January 26th

    You assume wrong. Mplayer’s dumpaudio makes it dump the audio stream as it is in the video file, which is essentially the best audio quality you can get out of that particular video file…

    Making ffmpeg reencode the stream at a higher bitrate is, as was previously mentioned, a complete waste of time and space :-)

  23. I am using ffmpeg 0.5 and it complained when I ran the command as written above (-ab 128) that teh bitrate was too low and that ffmpeg takes the number as bit/s not kbit/s.

    So, I reran the same command with:

    ffmpeg -i nodame_theme.flv -ab 128000 -ar 44100 nodame_theme.mp3

    and now the bitrate reported is 128kb/s.

  24. In addition to all said about changing bitrates is useless. Currently the audio from most flv youtube videos is not codified as mp3 but as AAC, so you need to recodify it as mp3 with loss of quality, I don’t recommend it.

  25. Anish Sneh Says:

    Thanks mate, it rocks

  26. Thanks, this is exactly what I was looking for!

    Btw, to complete the conversation about re-encoding the sound track, it can be useful to do that if you want to play it with a device that has limited capacities. Some MP3 players are really picky.

  27. mp4 videos don’t seem to work…

  28. Thanks for your posting. Another element is that to be a photographer will involve not only issues in capturing award-winning photographs but hardships in acquiring the best photographic camera suited to your requirements and most especially struggles in maintaining the quality of your camera. This can be very true and visible for those photography fans that are straight into capturing the actual nature’s engaging scenes — the mountains, the particular forests, the wild and the seas. Going to these daring places undoubtedly requires a photographic camera that can live up to the wild’s harsh surroundings.

  29. Thanks first. Is there a program that can extract all video as audio files straightly and easily? I have checked that there is a very good program which is called streaming audio capture(http://www.capturestreamingaudio.net/) for us. Share for you.

  30. Quieres conocer nuevas amigas

  31. Hey all I used to be just checkin out this web site and that i really admire the foundation want to know

  32. LOL. “Okay, The audio extracted from flv, so quality is quite low, haha. But you can change the audio rate by using ffmpeg. Let see how to use ffmpeg.”

    EPIC FAIL! Is this a troll post or are you really that dumb?

    Because if you are, I bet you also think renaming a Word document (your “image” format of choice) with a embedded BMP to “.jpg” will make it a JPEG image. ^^

  33. Too many folks have already thrown away plenty of good money on nothing but useless
    salt tablets being shipped from South America.

    In fact, I always suggest to those overweight vegetarians
    to keep to a max of 4 pounds a week so you won’t suffer loose skin post weight loss. That way, the actual process will end up being much less frustrating and, for the majority of people, enjoyable.

  34. This helps business managers to determine what the general public thinks about their products or
    services. As an Internet broadcaster, it is high time that you pick on these available opportunities and
    add that $ilver sheen to your broadcasting happiness.

    Having had my nearby store shut down recently I looked around for another place where I could get my gear from but unfortunately could not find any good outlets
    even remotely close to my home so started looking online.

  35. the how about extract file audio .mp4?
    thx

Leave a Reply