How to play DVDs on virtually any GNU/Linux distro

by Terrell Prude', Jr.

A few years ago, my folks bought and sent me two DVDs as a gift, 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 DVDs. I'll walk you through the easy steps required.

When I first wrote this HOWTO in mid-2004, I originally 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. Further, everything except for the extra codecs package also applies to GNU/Linux on non-x86 platforms, such as PowerPC. I've since done this procedure on Slackware GNU/Linux versions 10.2 through 12.2, Yellow Dog Linux 4.0 through 6.0, CentOS 4.2 and 5.0, lots of Fedora releases, Ubuntu 6.06 through 8.04, Debian GNU/Linux 4.0 and 5.0, and (with slight tweaks) OpenBSD 4.0.

But wait! Why would we do it this way when we have repositories like RPMForge and Debian/Ubuntu Universe or Multiverse? Simple. Not everyone is running those distros. And what happens if the RPM/DEB package maintainers get tired of doing the packaging? What will you do then? Yes, this kind of thing has happened in the past. Finally, I've discovered that sometimes options are left out that (for my hardware) should be there...or options that should not be there (e. g. OSS on a distro that supports ALSA)...got compiled in. The only real way to fix that is to compile your own.

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 use screen resolutions of 1152x864x32 bits or more. I currently use a Matrox Marvel G400TV, but MPlayer worked great with an ATI Xpert98 as well. Yes, I know, these are now viewed as "old", but they still work well. So yes, you can do this with an "older" video card.

You'll need a decent CPU, but unless you're watching the really hi-def stuff, it doesn't need to be the latest quad- or hex-core super-powerhouse. Far from it. On my 2GHz Athlon (the 2400+ model), top shows about 17% CPU usage with anything of standard DVD resolution. Given this, you ought to be fine with, say, a 1GHz Intel Celeron, especially if it's the Tualatin variety, and a 1GHz AMD Duron should be even better. That means that yes, that multi-core, uber-supercharged CPU that you likely just bought will certainly be quite enough!

Have at least 256MB of DRAM if you're running either GNOME 2.x (I originally wrote this using GNOME 2.6) or KDE 3.x (I currently use KDE 3.5), 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 back in 2004 originally had 512MB DRAM. Today, that same box has 1.5GB DRAM. Just about all modern boxes these days come with at least 1GB, and very often with 2GB, so for all practical purposes, this is no longer a concern.

Finally, you will, of course, need at least a DVD-ROM drive. Mine is, like most built today, a combination DVD/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, including the 1GHz Celeron Tualatin. You can probably go lower, but I wouldn't recommend it. Not that that's likely, anymore, given today's hardware, but I keep this admonishment here for completeness, in case someone is doing it on what is now considered an "older" box.

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 via the ports system. While I haven't yet watched DVD's on FreeBSD, I have done so on OpenBSD. With all versions of Slackware GNU/Linux, I did a "full" install, to ensure I had all the header and other "dev" files necessary for compilation.

You will need the software to actually play multimedia. Slackware comes with Xine, but the included Xine segment-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- and Microsoft-like behaviour 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, if you're on an x86 machine, 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.

The recommended way to get MPlayer is to pull from the Subversion repository, like so:

$ svn checkout svn://svn.mplayerhq.hu/mplayer/trunk/

I do this in a subdirectory (I used /home/microman/Downloads) to keep things organized.

For those of you who've been using MPlayer for a while, you might remember when we had to download something called FFMPEG and install it manually via some not-exactly-intuitive UNIX magic. Thankfully, that is no longer the case, as FFMPEG is now integrated with MPlayer. All you need to do, therefore, is download the MPlayer source, and you get both MPlayer and FFMPEG.

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 your "scratch" directory (again, I used /home/microman/Downloads) and untar them all, like so:
  $ tar -xvjf codecs-essential-20061006.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."

First, let's dispel this notion that copyright infringement is theft in the United States, despite the repeated bleatings of the MPAA and RIAA. The Supreme Court ruled in 1985 that copyright infringement is in fact not theft, in the case of Dowling vs. the United States. Yep, it's true; look it up. That said, the vast majority of us are honest and pay for our stuff, fair and square. This article is about watching your legally purchased DVD's, not about how to infringe copyright. My Dad is a professional musician, and I know plenty of other great jazz musicians, so I certainly don't condone copyright infringement. If you want to "pirate" music or movies, may I suggest you get a job?

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 in Galileo's name 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.


Putting it together

Now that you have all the software, you need to make it ready for use. MPlayer requires that the other three things that we downloaded and untarred be set up before you deal with MPlayer itself. We'll do that, starting with the codecs. Just run the following commands, as root. We assume you're in your "scratch" directory here:
  # cp essential-20061006/ /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 used to say to simply copy the contents of the skin directory into /usr/local/share/mplayer/Skin/default. That has now changed. They now go into /usr/local/share/mplayer/skins/default. This matters if you want to run MPlayer in graphical mode. If the skin files aren't in this location, then MPlayer won't find the skin, and the GUIfied MPlayer will not start, though the command-line version will still work fine.

Since we want the GUIfied MPlayer too, we do the following:
  # mkdir /usr/local/share/mplayer/skins/
# cp phony/* /usr/local/share/mplayer/skins/default/
# chmod 644 /usr/local/share/mplayer/skins/default/*
# chown root:root /usr/local/share/mplayer/skins/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 (actually typefaces, for those of you who know better). 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 skins
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

If you're running a 2.6 kernel, this may work better for you:

# modprobe 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 http://gatos.sourceforge.net/ 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. I haven't personally tried the ATI drivers with either X.org or a newer XFree86, as I switched to the Matrox card a while back. 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/
$ ./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/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. If you're running a Linux 2.4 kernel, then ATAPI CD-RW drives, including those with DVD playing functionality, require that you throw the hdX=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. This is not true if you're running a 2.6 kernel; IDE devices are treated differently under Linux 2.6, and the device name is something like /dev/hdc or /dev/hdd.

Here's how the device mapping ended up in my machine, running the 2.4 kernel:

/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 simply moved the /dev/dvd symlink to point to /dev/sr1.

I also had to tweak the permissions on /dev/sr1 (again, this may be, say, /dev/hdd on Linux 2.6). In every GNU/Linux distribution I've used, the device nodes for DVD drives are set to permissions of 660, with owner root. This is fine if you're running Linux 2.6. However, if you're running Linux 2.4, that permissions setting 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

On a 2.6 kernel, you don't need to do this.

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. And remember, The Matrix is watching you...Mr. Anderson....

Possible Display Bug Alert!

I have recently experienced a bug, relating to some versions of X.org, which can cause problems with using the "Xv" video output driver. Others have encountered it as well. Apparently, over certain horizontal resolutions (576 pixels, I think), MPlayer will produce a solid blue video output and repeatedly output an error message claiming "not enough resources". This is confirmed to be an X.org bug, not an MPlayer bug, as the problem affects all video players, e. g. Xine or GXine.

If you are experiencing this issue, then try using a different video output driver from within MPlayer, just as a test. I used "-vo gl2" to specify the newer OpenGL driver. It uses more CPU, but it did fix the problem. The VESA driver ("-vo vesa"), while very slow, should also work with all video cards. In my case, I have a Matrox Marvel G400TV video board (basically a Millenium G400 with a TV tuner), so I am able to use the "mga" video output driver, which also solves the problem and uses virtually no CPU.

Another possible remedy is to compile either an slightly older version of X.org (http://www.x.org), or perhaps XFree86 (http://www.xfree86.org). This is a somewhat more involved step, but I've compiled XFree86/X.org before, and it actually is not difficult. Just remember to back up your /usr/X11R6 directory first, and yes, that means before you begin.

Copyright (c) 2004-2007 Terrell Prude', 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
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301
United States of America

or on the Foundation's Web site, http://www.gnu.org/.


Last updated on June 28, 2009

Back to Homepage


Use LibreOffice    GNU GPL v3    Powered by ApacheOpenBSD--Free, Functional, and Secure    K-12 Linux Terminal Server Project