Linux: Extract Audio From Video File (Video To Mp3)

How do I extract audio from video file such as .avi/.mpg/.flv in Linux and UNIX and convert it to .mp3 file?

You can use mplayer which is a movie player for Linux and UNIX. It can play most MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files, supported by many native and binary codecs. You can watch VCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV and even H.264 movies, too. The same tool can be used to covert or extract audio from files. The syntax is as follows:

mplayer -dumpaudio -dumpfile output_filename.mp3


  1. -dumpaudio : Dumps raw compressed audio stream to ./stream.dump (useful with MPEG/AC-3, in most other cases the resulting file will not be playable). If you give more than one of -dumpaudio, -dumpvideo, -dumpstream on the command line only the last one will work.
  2. -dumpfile filename.mp3 : Specify which file (filename.mp3) MPlayer should dump to. Should be used together with -dumpaudio / -dumpvideo / -dumpstream.

Task: Extract Audio From .AVI File

Type the command as follows to extract audio from clip.avi to clip_track.mp3:
$ mplayer -dumpaudio -dumpfile clip_track.mp3 clip.avi
You can play extracted audio with mplayer command itself:
$ mplayer clip_track.mp3

Task: Extract Audio From VCD or DVD Track

The following command will extract audio from vcd track # 4:
$ mplayer vcd://04 -cdrom-device /dev/sr0 -dumpaudio -dumpfile /tmp/track04.mp3
The following command will extract audio from DVD track # 4:
$ mplayer dvd://04 -cdrom-device /dev/sr0 -dumpaudio -dumpfile /tmp/track04.mp3
You can extract track 5 to 10 using the bash for loop as follows:

for i in {05..10}
  mplayer vcd://$i -cdrom-device /dev/sr0 -dumpaudio -dumpfile /tmp/track$i.mp3

Task: Extract Audio From Stream

Use the following syntax:
$ mplayer -dumpstream -dumpfile /tmp/stream_03.mp3

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • patrick295767 Jun 18, 2013 @ 4:50

    Methods Outdated.

    Please update your page!

    Sincerely yours

  • iUser Jun 20, 2013 @ 0:32

    The current method as of the day 20th June 2013 works fine
    I just did few dumps that way and hey every one of them took like one second each
    GUI programs would probably do it longer, impressive

  • akitta Jun 24, 2013 @ 22:19

    It didn’t work for me..
    Trying to rip .mp3 audio from a Flash video..????
    It creates the file there is just nothing in there (well 4.6mb) but 0sec duration.??

    • LiuYan Jun 12, 2014 @ 10:13

      the manual said: -dumpaudio Dumps raw compressed audio stream to ./stream.dump (useful with MPEG/AC-3, in most other cases the resulting file will not be playable). So, I guess your audio codec isn’t mp3(MPEG audio)

  • Donald Gudehus Jan 13, 2015 @ 3:04

    I downloaded the mplayer binary for Mac OS X. I would like to extract an mp3 file from an avi file, but I don’t see how to do it, since the downloaded program,
    “MPlayer OSX” doesn’t work on the command line.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum