Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
By mhearn at 2003-07-28 11:06
OK, so you want to watch a DVD or video file on Linux but you aren't sure where to start. Typically Linux distributions do not come with DVD/video playback working out of the box, for reasons explained below, so you will have to find and install a player program yourself. This article also explains how to do things like enable DMA (useful if your DVD playback performance is poor) and crop video images if you get a widescreen DVD by accident.
Firstly, why does Linux not come with this ability as standard? The basic problem is that some countries have laws against breaking copy protection technologies. You may, or may not, be aware that DVDs are encrypted. This is for many reasons, the official one being to prevent piracy (which is certainly valid), other reasons include attempting to enforce region encoding and controlling the supply chain. You can only decrypt a DVD if you know one of the encoding keys, which require contracts and by keeping the keys secret, the DVD Consortium could control DVD playback.
Unfortunately, licensing these decryption keys costs a lot of money, and nobody wanted to write a commercial DVD player for Linux and the Linux community wanted an open source player. Several teams (not any officially connected with Linux btw) worked on cracking the encryption system and pretty quickly a method was discovered by which the keys could be extracted from the disks. Once this technology was developed, DVD playback in Linux became possible. When you play a DVD for the first time in Linux, there may be a short delay while the encryption is broken on the disc (typically players cache the extracted keys so if you play it again, there is no delay). It takes about 10-20 seconds for a standard length disk.
Similar issues have until recently prevented playback of video files like RealVideo and Windows Media streams on Linux. Fortunately today all common codecs and video encryption systems in use have been successfully reverse engineered and playback is usually possible.
So, let's have a look at your options. The reason DVD playback and video file playback are both covered by this article is because the programs that do them, often do them both. It therefore makes sense to talk about both at once.
The first thing you need is a player. If you are an American citizen by downloading and installing a player you may place yourself in violation of the law (the DMCA), however nobody has ever been prosecuted for playing DVDs or videos on Linux. Just be aware of the issues involved.
There are many good players on the market these days. Popular ones include Xine and MPlayer. There are other players available, but they normally make use of either xine or mplayer behind the scenes.
I personally recommend Totem, which can be found at http://www.hadess.net/totem.php3 - be aware that if you use Red Hat 9 or lower, or Mandrake 9.1 or lower, you may experience problems with this app (hangs, freezes etc). It's due to a bug in XFree which should be fixed in the next version, but as this howto may be around for some time I'm recommending it anyway. Not everybody has these problems, YMMV. Apparently it works OK on SuSE. Totem is based on Xine, so can play any file Xine can. Totem is certainly the easiest way to watch videos on Linux - if you find Xine or Mplayer too baffling, it's worth giving this a try.
To play DVDs or video files in Totem, just use the menus and toolbars. It works in a fairly obvious fashion. It has a nice fullscreen mode as well, and can do visualisations for audio files, if you like that kind of thing.
MPlayer can be found at http://mplayerhq.hu/ and has many devoted users. It can be rather hard to use, so make sure you read the documentation before asking questions. It can play virtually anything however with the right plugin packs - an ability that to my knowledge no other media player has. To play DVDs, run it like this:
mplayer -dvd 1
If you want mplayer to play Microsoft or RealMedia files, you may need to install a codec pack, which is available on their website. Just follow the instructions, and ask here if you get stuck.
Xine on its own is also popular, however the user interface for this is quite possibly even more baroque than MPlayers. One hint - an "MRL" is xine-speak for a dvd or movie file. Get it at http://www.xinehq.de/
You might have problems during DVD playback. One common issue is stuttering and skipping. If you have high CPU load during DVD playback, that's probably because you don't have DMA mode on. DMA mode is a special mode of IDE devices like hard disks, cd/dvd drives, zip drives and so on. Enabling it can make things go much faster, but on a few (old) chipsets it can cause bad things to happen like data corruption etc, which is why Linux doesn't switch it on by default.
As of the time of writing, there are no GUIs for enabling this mode (feel free to help us write one). You may not have had to enable this in Windows, as typically the hardware manufacturer will enable it for you at the factory (assuming you bought your computer with windows pre-installed). For obvious reasons Linux does not have this luxury, so you may have to enable it yourself (the $ indicates you should type the following in):
(enter root password)
$ file /dev/dvd
/dev/dvd: symbolic link to /dev/hdb
$ /sbin/hdparm -d1 /dev/hdb
Bear in mind that the exact name of the device may not be /dev/hdb on your system. Once you verify the command works you may want to add it to your startup scripts.
Red Hat users may find this doesn't work. Starting with Red Hat 8, from the release notes:
# DMA is disabled on CD-ROM drives in this release in a different but more reliable way than previously. If you are sure that your CD-ROM drive is capable of IDE DMA, place the following line in the /etc/modules.conf file:
options ide-cd dma=1
Finally, you may find that DVDs have large black bars at the top and bottom. That's because you don't have a widescreen monitor. Luckily, all is not lost, at least in MPlayer there is a trick you can use to blow the image up. You lose some of the picture at the sides, but that's OK because nothing important ever happens there anyway. Try investigating the -vop crop option on mplayer. There are instructions in the man page. Using this option can be convoluted because you must manually specify the crop rectangle. When you run mplayer, it will print out (somewhere) the size of the movie, for instance "720x568". Take the number on the left (the width) subtract N, where N is the value you want to scale by (200 is a good one to start with), then use "-vop crop 720-N:568:N:0" or some variation of that theme.
Totem can do this automatically, and there are zoom menu options for it.