Hack53.Play Restricted Media Formats


Hack 53. Play Restricted Media Formats

For licensing reasons, not all distributions come preconfigured to play several popular media formats, but setting this up is not difficult.

Out of the box, many Linux distributions do not include support to play a few restricted media formats, such as DivX, Windows Media (WMV), Quicktime, and DVDs. The distros don't include the codecs to play these formats due to licensing restrictions. However, you can download the codecs yourself and use them with media player backends such as MPlayer and xine. Getting DVDs to play is a bit trickier.

3.8.1. Playing non-DVD Media Formats

MPlayer is a cross-platform multimedia player that is quite popular on Linux. The makers of MPlayer host the sites where you can obtain the codecs for media formats that aren't normally supported on Linux. These codecs are usually the Win32.dll files that are used on Windows systems, and MPlayer is programmed to let you use these codecs on Linux. You can obtain the most commonly used media codecs by downloading the essentials package from http://www.mplayerhq.hu/homepage/dload.html. These codecs can be used with the other popular media player on Linux, xine. Uncompress the download and put the contents in /usr/lib/win32, which is where MPlayer and xine will look for codecs by default:

 $ tar -jxvf essential-20050216.tar.bz2 $ sudo cp essential-20050216/*/usr/lib/win32/ 

Restart your media player, and you should now be able to play most restricted formats. For a full list of formats that are supported, visit: http://www.mplayerhq.hu/homepage/design7/info.html.

MPlayer and xine each have several frontend GUIs, such as kMPlayer, Kaffeine, namp, Totem, and oxine. So, regardless of the media player your distribution is configured to use, you can probably drop the codecs into the /usr/lib/win32 directory and have it just work.


3.8.2. Playing DVDs

Getting encrypted DVDs (most commercial DVDs) to play on your Linux box is usually a bit trickier than adding codec support. To playback these DVDs, you essentially need three things: a playback engine that supports DVD playback, the libdvdread library, and the libdvdcss library for decrypting the content. A system that has a DVD playback-capable engine and libdvdread installed but doesn't have libdvdcss can play back only unencrypted DVDs. A system that has libdvdcss installed but doesn't support DVDs in the playback engine can't play any DVDs.

The media engines most often used for DVD playback are MPlayer and xine. Depending on your distribution, these engines may or may not already have support for DVD playing. Rather than working around this uncertainty, it is often best just to grab a DVD-capable mplayer or xine package from a thirdparty site. Since you'll nearly always need this site to add libdvdcss, it's no more work to grab your playback engine from there as well. libdvdread is usually installed as a dependency of your playback engine. If it isn't, you can use either the one packaged by your distribution or one found on a thirdparty repository.

To obtain the necessary software, Fedora users can choose from among several package sites, including http://rpm.livna.org and http://freshrpms.net. Both sites contain easy-to-follow instructions for adding the repositories to your Yum or apt-rpm configuration. Once enabled, installation is as simple as:

 # yum install mplayer libdvdcss 

Or for apt-rpm users:

 # apt-rpm update # apt-rpm install mplayer libdvdcss 

Mandriva users need to add the Penguin Liberation Front (PLF) repository in order to install libdvdcss. The versions of MPlayer and xine installed with Mandriva already support DVD playback. An easy way to add the PLF repository to your setup is to visit the website http://easyurpmi.zarb.org and follow the insructions found there. This site is simply a web-based form that asks a few questions about which version of Mandriva you are using, which repositories you'd like to add to your configuration, and which mirrors you'd like to sync with. After you answer the questions, the web page displays the commands you need to type in a terminal to enable the repositories. It takes only a minute or two to set this up. When you are done, the command to install libdvdcss is:

 # urpmi install libdvdcss2 

Note the 2 in this command. Depending on your distribution, this may be how your version of libdvdcss is packaged.

In addition, you can find RPMs of libdvdcss that should work on most RPMbased distributions at http://cambuca.ldhs.cetuc.puc-rio.br/xine/. You can also find a build of xine that supports DVD playback.

Once you have both software packages installed, DVD playback is as simple as inserting the disc, loading your media player application, and pressing Play. To view a movie with MPlayer, the command is:

 $ mplayer -fs dvd:// 

This opens the movie in fullscreen mode and begins immediate playback of the movie. [Hack #48] provides more details about controlling video playback.

To do the same with xine, here is a recommended command:

 $ xine -pfhq --no-splash dvd:// 

This command will autoplay the DVD (-p) in fullscreen (-f) with the xine GUI hidden (-h) and will quit the application when the movie finishes (-q).

Running xine from the command line requires that the xineui package be installed. Depending on your distribution, this may have not been done for you when you installed the xine libraries.


[Hack #14] shows you how to configure Linux for surround sound and enable MPlayer and xine support for multi-speaker output.

DVD playback requires quite a bit of processing power. Depending upon your setup, you may be able to get by with a processor as slow as a Pentium II 500 MHz, but you probably can't go any slower than that. If playback is jerky but you have plenty of processor might, your problem may be that your DVD drive does not have DMA enabled. Enabling this with hdparm is covered in Linux Desktop Hacks and on numerous web sites.

David Brickner




Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
EAN: N/A
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net