[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Thursday, 22 February 2001 | Author: Kenny Sabarese |
Published to: enhance_articles_multimedia/Video Articles | Page: 1/1 - [Std View] |
Playing DVDs with Xine
Ever wondered how to watch a DVD under Linux? Kenny Sabarese gives a step by step tutorial all the way from compiling the kernel correctly, to enjoying the movie.
|
To my surprise, not only was DVD playback possible, it was much easier then I expected. After sorting through a few packages and bugging the friendly people in #xine on Openprojects, I got to watch my SNL 25th Anniversary DVD while checking Slashdot in Mozilla and compiling kernel 2.4.1. In this article, I hope to break down the process into a few simple steps.
First I'll let you know the specs on my machine:
Step 1: Your Kernel
First let's make sure your kernel is up to date and has all the right features compiled in. A 2.4.x kernel will yield better results than a 2.2.x in most cases. I recommend 2.4.x or 2.2.18. Also, there is a known bug in 2.4.1 that prevents reading DVDs to the end on certain drives. It should be fixed by 2.4.2. If you notice the problem, try 2.4.0 or wait for 2.4.2 to be released.
Probably the most important part of the kernel config is compiling in MTRR support. It's located in the "Processor Type and Features" section of the kernel configuration. MTRR (Memory Type Range Register) support, simply put, helps your CPU and video card talk to each other more efficiently. I first tried without this option, and playback was slow and jumpy. You can check if you have MTRR kernel with the following command:
cat /proc/mtrr
You should get output similar to this:
kfs@celery$ cat /proc/mtrr reg00: base=0x00000000 ( 0MB), size= 128MB: write-back, count=1 reg01: base=0x08000000 ( 128MB), size= 64MB: write-back, count=1 reg02: base=0x0c000000 ( 192MB), size= 32MB: write-back, count=1 reg03: base=0xd0000000 (3328MB), size= 128MB: write-combining, count=1 reg04: base=0xdc000000 (3520MB), size= 32MB: write-combining, count=1As long as you get output when you run the command, you should be OK. Every machine will have a different output, so don't worry if yours looks totally different than what I have here.
You will also want to make sure that you compile in support for your specific motherboard chipset in the "IDE, ATA and ATAPI Block device" section of the kernel configuration. This will improve performance and allow you to set the drive to use DMA, which we will get into later. Most distributions have DMA auto assign enabled by default in their kernels, but you should probably compile your own kernel for best performance.
Step 2: /dev/dvd
Next let's setup a device called /dev/dvd. Xine looks to /dev/dvd by default when it attempts to play a DVD. We need to make a symlink to the DVD-Rom with the following command: (replacing the X with the letter corresponding to your drive):
ln -s /dev/hdX /dev/dvd
We also need to have 1777 permissions on the DVD-Rom drive. This is because xine needs to be able to "write" to this device in order to play the DVD. This will also allow any user to play DVDs, so you don't have to run X root user. We can do that like this:
chmod 1777 /dev/hdX
Note: Debian users should add users who want to play DVDs to the disk with the command "adduser (username) disk". Then login again.
Step 3: Drive Optimization
Next we need to make sure that the DVD-Rom drive is running as fast as it can. To do this we want to have DMA (Direct Memory Addressing) enabled on the drive. We do this with the utility hdparm.
To test if you have DMA enabled:
hdparm -d /dev/dvd
You should get the following output:
root@celery:~# hdparm -d /dev/dvd /dev/dvd: using_dma = 0 (off)If it says "1 (on)," you guessed it, you have DMA enabled. You can move on to Step 4. If the output is "0 (off)," then DMA is not enabled. To fix this, we again use a very similar command:
hdparm -d 1 /dev/dvd
When you execute this command, you should see output similar to the first command we ran, but there will be "1 (on)."
Doing this command once is not sufficient if you ever reboot your machine. If you want DMA to be enabled whenever you boot Linux, you will need to put the "hdparm -d 1 /dev/dvd" command somewhere into your startup scripts. If your DMA was on by default, then you don't need to bother with this step.
For some more information on increasing drive performance, check out: these resources.
Step 4: The Software
A: Xine
First we need to get xine. As of this writing, the latest version is 0.3.7. Though we can use distro-specific packages, everyone I spoke to while getting this working on my own machine encouraged me to compile from source. This will make things easier later when we have to go back and try different library packages and plugins to see which perform best on your hardware.
Get the xine source tarball from: sourceforge.
I put all the packages into a directory in my home directory called "dvd." This may sound silly, but some of the other package names are very similar to each other, and I would mistake them for each other until I got them all separated from the mess in my home directory.
As with most other source tarballs, untar, ./configure, make, make install. Test that xine runs with a simple "xine" at the prompt. If you have an mpeg movie around, try playing it with "xine file.mpg". And last, check that fullscreen mode works by pressing f while the movie is playing.
For more info on xine, go to Xine's Homepage
B: Get libcss
Libcss contains the libraries you need for decoding DVDs. The best performing version of libcss is available via CVS. First make sure you have your distro's CVS package, libtool and automake (I was missing these on my system) installed, then do the following commands:
export CVSROOT=:pserver:anonymous@cvs.linuxvideo.org:/cvs/livid cvs login (no password needed) cvs -z3 co libcssThis will download the source into a directory called libcss. Go into this directory and run "./bootstrap." This will prepare the source to be compiled with a typical ./configure, make, make install.
Now if you have problems with the CVS or notice problems with DVD playback, you may want to try the current release of libcss, which is version 0.1.0.
You can download the tarball from: Linuxvideo.org.
Note: If you switch to this package after using xine with the CVS libcss, you should re-run "make install" for xine as well as the xine css plugin that you choose to use. You may also want to run ldconfig to make sure all libraries are up to date.
For more information on libcss visit Linuxvideo.org
C: The xine CSS Plugin
Now that we have xine ready and libcss waiting to be used, we need to get the two to talk to each other. For this, we need to use one of the two available CSS Plugins. It is recommended that you try both since one may have better performance than another or not work at all. On my machine both the Libcss Plugin and the Captain CSS Plugin worked. Try both, and let me know which one works or which works best if both do work.
Libcss Plugin: http://www.nott.ac.uk/~psystrj/xine_dvd_libcss_plugin.tar.gz
Web Site: xine.cjb.ne
Each package installs with a simple untar, ./configure, make, make install. Once you have installed xine, libcss, and one of the plugins we just need to do one more thing. Run the command "ldconfig" as root to make sure the programs know where to look to get all the libraries you've upgraded.
Once you've gotten all this done, we can finally run xine! Put a DVD into your drive and fire up xine from a terminal. Keep the terminal open and in view so you can take note of any messages it spits out.
Click on the "DVD" tab in the green control panel window. It should read the DVD-Rom and then show the title of the disc in the display or just show something like "dvd://t0c0t0," which is what I saw when I put in my SNL 25th Anniversary DVD. Now hit play and cross your fingers . . .
Within a few seconds you should see your movie start to play. If the movie stutters as it plays, make sure you are using DMA on the drive and have MTRR in your kernel. If you still have problems, try using the other plugin or a different version of libcss then the one you installed. When trying a different plugin or different version of libcss, you should re-run "make install" for xine, libcss, and the plugin over again. Finish it off with an "ldconfig," and the new packages should be ready to go.
If you are still having problems, check out the web pages that I have referred to in the article or drop into irc.openprojects.net and join then #xine channel.
Some other options that are available for plying DVDs in Linux:
Open Media System: http://www.linuxvideo.org
LinDVD: http://www.lindvd.org
VideoLAN: http://www.videolan.org
Update (2-23-2001): there is a newer libcssplugin that works much better, it is available at:
http://www.kuroyi.net/xine/xine_dvd_libcss_plugin-clut.tar.gz
Good luck, and let me know how you make out.
-Kenny Sabarese
kfs@leftearmusic.com
irc.openprojects.net #linuxhelp
Kenny Sabarese is a 20 year old student at Susquehanna University and drummer for Not Another Greek Tragedy. He has been a Unix user for 3 years.