August 31, 2004

How to play DVDs on any x86 GNU/Linux distro

Author: Terrell Prudé, Jr.

My folks recently bought and sent me two DVDs, but the only DVD player I have is in my Linux-based computer. Using the free software application MPlayer, I was able to watch my videos. I'll walk you through the easy steps required.I used Slackware GNU/Linux v10.0 on an AMD Athlon, but the techniques apply to any distro on x86 hardware and even to BSD-based operating systems. I'll assume here that you are a user of GNU/Linux, that you're running the X Window System with some window manager (it doesn't matter which), that you know how to get to a command prompt and do basic directory navigation and file manipulation, and that you know what a symbolic link is.

Hardware requirements

First, you'll need a sound card -- any sound card that works with your operating system -- and a decent video board -- anything from an ATI 3D Rage Pro onward. You really don't need more than 4MB video RAM unless you like screen resolutions of 1152x864x32 bits or more. I currently use a Matrox Marvel G400TV, but MPlayer worked great with an ATI Xpert98 as well.

You'll need a fast CPU. On my 2GHz Athlon (the 2400+ model), top shows about 17% CPU usage. Given this, you ought to be fine with, say, a 1GHz Celeron, especially if it's the Tualatin variety, and a 1GHz Duron should be even better.

Have at least 256MB of DRAM if you're running either GNOME 2.x (I'm currently using GNOME 2.6) or KDE 3.x, so you don't swap to disk and slow down your box during video playback. As always, if you can afford it, go for more; my box has 512MB DRAM.

Finally, you will, of course, need a DVD-ROM drive. Mine is, like most built today, a combination DVD-ROM/CD-RW drive with an ATAPI interface. It is plugged into the secondary IDE channel as the master. I also have a SCSI CD-RW drive in this box which, while obviously not used for DVDs, did have a small device-naming effect, which I'll explain later.

I've used these hardware components myself with success. You can probably go lower, but I wouldn't recommend it.

Software requirements

For software, to begin with, you'll need some general-purpose GNU/Linux distribution. For the BSD folks out there, I know that MPlayer works nicely on FreeBSD and OpenBSD, because I've tried it. I've just not yet tried DVDs on those operating systems, though they should work the same way. With Slackware GNU/Linux 10.0, I did a "full" install, just to be safe.

You will need the software to actually play multimedia. Slackware comes with Xine, but the included Xine seg faults when I try to play my legally purchased DVDs, so, unfortunately, the stock Xine will not work for this purpose. This is true of most distros sold in countries influenced by the Motion Picture Association of America's SCO-like behavior when it comes to DVDs on free software. Thus, I chose something that has that ability built-in: MPlayer, from the great nation of Hungary.

Download the latest version of the MPlayer source code, and the "essential" pack of codecs, which will allow you to play Windows Media and certain other proprietary formats. These codecs are not necessary to play DVDs, but they do make MPlayer a much more generally useful tool. To play DVDs, you should download a fonts package (I use Arial-Western-ISO-8859-1, since I'm an English speaker), and
at least one "skin," which is an absolute necessity to run the GUI version of MPlayer.

If you're familiar with Mozilla or XMMS skins, then MPlayer skins are the same idea. Note that there is no "default" skin, so you have to download a skin if you want to use the GUI version of MPlayer. I recommend this for playing DVDs, though you can use the command line version as well.

Put all of these in some directory (I used /home/microman/Downloads) and untar them all, like so:

  $ tar -xvjf MPlayer-1.0pre5.tar.bz2
  $ tar -xvjf codecs-essential-20040704.tar.bz2
  $ tar -xvjf font-arial-iso-8859-1.tar.bz2
  $ tar -xvjf skin-phony-1.1.tar.bz2
What about the MPAA and RIAA?

You may wonder about the legality of all this, and it's a valid question. I am not advocating that anybody break the laws of their countries or localities. As "DVD Jon" Johansen discovered, the MPAA and RIAA like to whine, complain, and threaten criminal legal action against people in certain countries simply for playing DVDs using free software, claiming that merely by watching our legally purchased DVDs, we are "criminals" and "stealing" their "intellectual property."

There will always be a few criminals who will do anything in order to steal or do damage to people. The vast majority of us are emphatically not like that.

After I watched "The Matrix Reloaded," I enjoyed the movie enough to go out and buy the sequel, "The Matrix Revolutions." Yes, I actually went out and bought another DVD with cold, hard cash, when otherwise I wouldn't have done so. Makes sense; if I can't watch a DVD in the first place, why would I go out and buy one?

Thus, the ability to play DVDs on free software actually resulted in more profit for Warner Bros. It's a win-win situation, because the studios make money, and I get to watch cool movies, all on the up-and-up. The MPAA and RIAA should stop this silliness over region specificity and copy protection and just get on with producing more great content for us to buy.

Next, head over to the FFMPEG Web site and download the current version of this audio/video conversion tool:

$ cvs -z9 co ffmpeg

This command automatically retrieves a copy of the FFMPEG source from the developers' own repository and puts it in the ffmpeg subdirectory on your hard disk.

Putting it together

Now that you have all the software, you need to make it ready for use. MPlayer requires that the other four things that we downloaded and untarred be set up before you deal with MPlayer itself. We'll do that, starting with FFMPEG, which, being from CVS, is already untarred for us. First, cd into your ffmpeg directory, then run the commands:

  $ ./configure
  $ make
  $ su root
  # make install

This compiles and installs the FFMPEG software in /usr/local directory tree.

Now get the codecs ready. You need to remain root to do this:

  # cd ..
  # cp essential-20040704/ /usr/local/lib/codecs/
  # chmod 644 /usr/local/lib/codecs/*
  # chown root:root /usr/local/lib/codecs/*

You need to make sure that your permissions are 644 or 664, with owner as root:root. Slackware appears to apply, by default, permissions of 640 to files when you're root; this is actually good security practice. Yes, mv instead of cp also works.

Now for the skin, still as root. Note that the MPlayer directions say to simply copy the contents of the skin directory into /usr/local/share/mplayer/Skin/. This is wrong. They actually need to go into /usr/local/share/mplayer/Skin/default/ or MPlayer will not find the skin and the GUIfied MPlayer will not start:

  # mkdir /usr/local/share/mplayer/Skin/
  # cp phony/* /usr/local/share/mplayer/Skin/default/
  # chmod 644 /usr/local/share/mplayer/Skin/default/*
  # chown root:root /uar/local/share/mplayer/Skin/default/*

The phony/ subdirectory name is not a typo; the skin that I chose is actually called "Phony," and it looks rather cool.

Now for the fonts. MPlayer looks for them, by default, in /usr/local/share/mplayer/font. There's a trick here as well, because when you untarred the fonts tarball, you actually got four subdirectories along with the README. Each of these directories represents the Arial typeface at a different font size. At my resolution of 1152x864, I chose the 18-point size. The best thing to do is to move the entire fonts subtree and do a symlink to the font size that you want. Here's how I did it:

  # mv font-arial-iso-8859-1/ /usr/local/share/mplayer/
  # cd /usr/local/share/mplayer
  # ls -l font-arial-iso-8859-1
  -rw-r--r--  1 root root  218 2003-07-13 20:02 README-arial-iso-8859-1
  drwxr-xr-x  2 root root 4096 2003-07-13 19:42 font-arial-14-iso-8859-1
  drwxr-xr-x  2 root root 4096 2003-07-13 19:42 font-arial-18-iso-8859-1
  drwxr-xr-x  2 root root 4096 2003-07-13 19:42 font-arial-24-iso-8859-1
  drwxr-xr-x  2 root root 4096 2003-07-13 19:42 font-arial-28-iso-8859-1
  # ln -s font-arial-iso-8859-1/font-arial-18-iso-8859-1 font

Make sure your ownership and permissions are what they need to be:

  # chmod -R 755 font-arial-iso-8859-1/
  # chown -R root:root font-arial-iso-8859-1

Your directory listing should now look like this:

  # ls -l
  total 8
  drwxr-xr-x  3 root root 4096 2004-08-21 20:23 Skin
  lrwxrwxrwx  1 root root   47 2004-08-21 20:41 font -> font-arial-iso-8859-1/font-arial-18-iso-8859-1/
  drwxrwxr-x  6 root root 4096 2003-07-13 20:02 font-arial-iso-8859-1

Preparing and installing MPlayer

Video acceleration

Want to install a video accelerator driver for added performance or to lower CPU usage? It is not strictly necessary, unless you're on an older box -- a 400MHz Pentium II, for instance -- and you want to avoid skipping. If things are working for you, you probably don't need to worry about it.

I decided to try adding a video accelerator driver with Slackware 10.0. The process is, by necessity, specific to each system's video card. I use a Matrox Marvel G400TV, which is just a Millenium G400 with a TV tuner. MPlayer comes with the source code for mga_vid, which is the driver for Matrox cards. I changed to the drivers subdirectory of the MPlayer source code directory, and ran make and make install. That builds the driver, and now we actually activate it with this command, as root:

# insmod mga_vid mga_ram_size=16

This inserts the driver into your kernel, telling the driver that your video card has 16MB of video RAM. Note that you should put this in your system startup scripts if you want the driver to automatically get loaded on your next reboot. On most GNU/Linux systems, it would go in your /etc/rc.d/rc.local file.

Once you do this, you also, I discovered, need to change the permissions on the /dev/mga_vid device node from 660 to 666 to make it world-writeable. I believe that this is because MPlayer needs to be able to write directly to that device node itself, since I'm using the special Matrox accelerator driver.

For ATI cards, head over to and follow the directions. They've got a set of binaries for X11, depending on your version. I had trouble with XFree86 4.2.0, but 4.1.0 and 4.3.0 worked nicely for me, so I'd recommend using either of those two versions if you can. I haven't tried the ATI drivers with or XFree86 4.4.x. You do not need to set any special permissions on any device nodes with the ATI cards as you do with the Matrox ones.

For other video cards, I don't know; I just haven't tried it. Read the MPlayer documentation. It's in the man pages and on their Web site and actually is fairly decent.

At this point, you're ready to tackle MPlayer itself. Exit out of root mode, because, for security reasons, you don't ever want to compile apps as root:

  # exit
  $ cd MPlayer-1.0pre5
  $ ./configure --enable-gui
  $ make
  $ su root
  # make install

Now, MPlayer is installed. It will look for DVDs in /dev/dvd, which, on my system, is a symlink to /dev/sr0. Make sure that this symlink is pointing to the right device. In my case, I have both a SCSI card with a SCSI CD-RW on it and an ATAPI DVD-ROM/CD-RW drive. It turned out that, on my system, the SCSI CD-RW was seen first by the SCSI subsystem code in the Linux kernel. ATAPI CD-RW drives, including those with DVD playing functionality, require that you throw the hdc=ide-scsi parameter in your /etc/lilo.conf (or, for GRUB users, /boot/grub/menu.lst) file during the operating system install. They are then treated as SCSI devices, which is required if you want to burn CD-Rs. Here's how the device mapping ended up in my machine:

/dev/sr0 = the SCSI CDRW drive.
/dev/sr1 = the ATAPI DVD/CDRW drive.

However, Slackware made both the /dev/dvd and /dev/cdrom symlinks point to /dev/sr0 instead of /dev/sr1. I moved the /dev/dvd symlink to point to /dev/sr1.

I also had to tweak the permissions on /dev/sr1. In every GNU/Linux distribution I've used, the device nodes for drives are set to permissions of 660, with owner root. That won't allow you to play DVDs -- you've also got to set world-readable permissions on your DVD device node (in my case, /dev/sr1):

# chmod 664 /dev/sr1

You're now ready to run MPlayer and play a DVD. Since we compiled the GUI version of MPlayer, you simply type gmplayer to start the program. Pop your DVD in, click the DVD button in MPlayer, and have fun.

Copyright (c) 2004 Terrell Prudé, Jr.
Permission is granted to copy, distribute, and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license can currently be found at the following address:

Free Software Foundation
59 Temple Place - Suite 330
Boston, MA 02111-1307

or on the Foundation's Web site,

Click Here!