Complete Guide to Playing Movies and Music on Linux
One of the caveats that many people have with using Linux is the current state of media support. While media playback on Linux is presently much better than it has ever been before, it still requires a little bit of know-how and tweaking to get everything working properly. This guide will go over each step of optimizing your media capabilities.
Why Doesn't Media Just Work?
The reason why some types of media do not work out of the box on Linux is due to legal and technological reasons. Many of the popular media formats (like DVD, MP3, Adobe Flash, etc.) require a codec, DRM workaround, or other sort of player before content in any of those formats can be viewed. Because of patent and copyright law, Linux distro maintainers are not able to include these extra packages in their distros, so media performance is somewhat crippled as a result. Some distros actually license these codecs (e.g. Mandriva's Codina tool) and have working media support out of the box. However, such features are not free and many people balk at the notion of paying for Linux. If it provides any reassurance, it helps to know that this problem is not specifically limited to Linux. Windows XP and some of the low-end editions of Vista are unable to play DVDs out of the box as well, and no version of Windows offers out of the box Blu-Ray support.
Even if you have the requisite codecs, you may still be hindered if the file you are trying to play is protected by strong DRM. Many people have gotten burned over the years by DRM-encumbered media that has a built-in time limit, requires a special player, or must “phone home” for license confirmation each time you want to play it. The last method is especially bad, since you will no longer be able to view the files you are legally entitled to if the media company suddenly shuts down the authentication server; this has happened several times in the past and customers were left high and dry in all instances. Aside from breaking the copy protection (which requires some skill in most cases in addition to being technically illegal thanks to the infamous Digital Millennium Copyright Act) there is little you can do in such instances except hate the media companies that insist on such strong measures.
On the other hand, Linux is capable of playing unencrypted DVD video (like discs you make yourself) and various open audio formats like OGG Vorbis and FLAC (Free Lossless Audio Codec) out of the box. CD audio and WAV also work without any tweaking. Most distros include a wide assortment of players that can handle almost any kind of media when properly configured.
Preparing your System
Although most distros are not able to ship codecs for every type of media out of the box, these codecs are relatively easy to come by from both official and unofficial sources. To facilitate ease of installation, virtually every codec is stored in a package that can be handled by a distro's package manager.
DVD Playback
The media feature that is essential to most people is DVD playback. Virtually every retail DVD sold off the shelf contains a fairly weak (by today's standards) 40-bit DRM encryption scheme called Content Scramble System, (CSS) meant to prevent unauthorized disc reproduction. CSS relies on decryption through keys located on a non-copyable area of the original disc, (the lead-in area) so any homemade copies made from the original disc will not have the keys necessary for decryption and will therefore be unwatchable. CSS-protected video is almost completely obscured by extensive multicolored blocking and artifacting when viewed without a means to decrypt it. (interestingly enough, the audio tracks are unprotected and may still be listened to)
Every standalone hardware DVD player or the various proprietary DVD player software programs (like PowerDVD) are capable of decrypting CSS so the video may be displayed properly. Doing this legitimately requires licensing various patents and key sets from the DVD Copy Control Association, so free software was mostly left out in the cold in the early years. As a consequence, it used to be impossible to watch (much less copy) DVD video on Linux, and the only reliable way to replicate DVD video back then was through analog capture. Several years ago, John Lech Johansen, working with other people who have never been identified, released a program called DeCSS that used a rather simple algorithm (the functional code of DeCSS can fit on a t-shirt) to break the CSS copy protection through a brute-force attack.
After the inner workings of DeCSS became widely understood, many derivatives of it became available, mainly to survive eradication attempts on the part of the media companies through sheer redundancy. While few systems still use the original DeCSS, the most common DVD decryption module for Linux systems is now libdvdcss2. Whereas the media companies fought aggressively against DeCSS, libdvdcss2 has largely been left alone.
Unlike DeCSS, (which relies exclusively on brute force) libdvdcss2 includes a pool of potential keys that are tested until a working one is found; if none of the keys work then brute force is used instead. Brute-forcing strong encryption is usually pointless, but today's computers can break the weak CSS encryption in anywhere from a few seconds to a few minutes.
Many players (like VLC) rely exclusively on libdvdcss. Once you install it for one player, it should work for all of them since it is a shared library. For Ubuntu, the package you need is called libdvdcss2. You can install libdvdcss through Ubuntu's libdvdread package, which is available in the main Universe repository. This method will acquire libdvdcss from the Medibuntu (the multimedia-focused variant of Ubuntu), make a package out of it for easy management, and then install it. To do this, you need only follow this procedure:
1. For Ubuntu 9.04 and up, run “sudo apt-get install libdvdread4”. For older versions of Ubuntu, use the libdvdread3 package instead of libdvdread4.
2. After the libdvdread4 package has been installed, open a terminal and run “sudo /usr/share/doc/libdvdread4/install-css.sh”. For libdvdread3, you should use “sudo /usr/share/doc/libdvdread3/install-css.sh”.
3. Your computer should now be able to play encrypted DVDs with any player that uses libdvdcss2.
Alternatively, you have the option to install the libdvdcss2 package manually. The actual libdvdcss2 package is not found in the standard Ubuntu repositories, (in the first method, you make the package yourself) but can be found in third party locations like the Videolan repository. To enable this resource in apt-get, do the following:
1. open /etc/apt/sources.list with your favorite text editor (sudo/root is required to save changes)
2. add “deb http://download.videolan.org/pub/videolan/debian sid main” as an entry in the sources.list file. Make sure it is all on one line and there are no line breaks. Although the version of libdvdcss in that repository is for Debian's unstable branch, it will work fine in Ubuntu 9.04 and older.
3. Save the sources.list file.
4. Run “sudo apt-get update” to refresh the package list and make libdvdcss2 available for download.
5. Run “sudo apt-get install libdvdcss2”.
6. The apt-get program will warn you that the package cannot be verified. Unfortunately, there is no GPG signature for that repository listed on the developer website, so you will have to install the package without verification. (In this instance, it is safe to do so)
7. Your computer should now be able to play encrypted DVDs with any player that uses libdvdcss2.