Live Chat!

extract audio from video or online stream

* * * * ½ 6 votos

March 1st, 2007 mysurface Posted in Misc, ffmpeg, mplayer | Hits: 44917 |

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.

20 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.

Leave a Reply