mp3dump: Rip the audio stream of a Flash video to MP3

UPDATE : Also check out mp3dump part 2

On some undefined occasion you might want to dump the audio stream of a flash file. This is how you do it:

  1. Get the *.flv, e.g. visit youtube with Konqueror and check /tmp for a file like FlashV5SQLt - this is your FLV.
  2. Install some dependencies: ffmpeg is required, mp3info and ecasound are optional but strongly recommended.
  3. Download the script below (it’s attached!) and save it inside your $PATH, remember how you’ve called it!
  4. I’ve saved the script inside ~/.bin which is inside my $PATH so all I have to do now is running it:

mp3dump FlashV5SQLt "Foo Bar" "All Your Base Are Belong To Us"

This would rip the audio stream of FlashV5SQLt to a file named Foo Bar - All Your Base Are Belong To Us.mp3 - with emulated stereo sound and basic MP3 tags (artist and title). Coolio!

So what does this neat-o-bash-magic look like?

Note: The script is attached below, so no copy’n’paste is required (but optionally supported :-) )

    # Simple script to rip the audio stream of a FLV to MP3
    # usage:      mp3dump INPUT.flv ARTIST TITLE
    # example:       mp3dump FlashhxSjv3 "Foo Bar" "All your Base are Belong to Us"
    # Author:        Milian Wolff
    # depends on:  ffmpeg
    #   optional:    ecasound for stereo sound emulation
    #   optional:   mp3info to write title and artist mp3 tags
    if [[ "$(which ffmpeg)" == "" ]]; then
     echo -e "\033[41mInstall ffmpeg or this script wont work!\033[0m"
    if [[ "$1" == "" || "$2" == "" || "$3" == "" || "$4" != "" ]]; then
      echo "Usage: $(basename $0) INPUT.flv ARTIST TITLE"
    dest="$2 - $3.mp3"
    echo "Destination file is: $dest"
    echo "generating mp3 file..."
    ffmpeg -i "$1" -f mp3 -vn -acodec copy "$dest" 1>/dev/null
    echo -e " \033[32mdone\033[0m"
    if [[ "$(which ecasound)" == "" ]]; then
     echo "You can optionally install ecasound to simulate stereo sound"
      echo -n "simulating stereo sound..."
        ecasound -d:1 -X -i "$dest" -etf:8 -o "$tmpfile" 1>/dev/null
        mv "$tmpfile" "$dest"
     echo -e " \033[32mdone\033[0m"
    if [[ "$(which mp3info)" == "" ]]; then
      echo "You can optionally install mp3info to write basic mp3 tags automatically"
      echo -n "writing basic mp3 tags..."
     mp3info -a "$2" -t "$3" "$dest"
     echo -e " \033[32mdone\033[0m"
    echo "Have fun with »$dest«"

PS: I totally forgot to mention that I got the basic ffmpeg & ecasound commands from this thread by SuperMike:

Attachment Size
mp3dump.1.35 KB


Want to comment? Send me an email!

Comment by Alan (not verified) (2009-06-29 22:44:00)

I always did it manually with mplayer -dumpaudio and then tagged it with eye3d. The tip about stereo sound is priceless. Thanks.

Comment by Jan (not verified) (2008-11-23 21:50:00)

thanks, was looking for some code for a new project. youtube does not use flv by any chance, does it?

Comment by Milian Wolff (2008-11-26 18:45:00)

Actually, it does:

As I mentioned at the beginning of the article, you can simply visit Youtube with your favorite browser under Linux and you’ll find the video you are watching somewhere under /tmp (look for cryptic names like FlashMYeMdJ). Make sure to rip before you close the page in your browser, else the temporary file will be deleted.

Published on November 26, 2008.