ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


FreeBSD Basics DVD Playback on FreeBSD

by Dru Lavigne
10/03/2002

Today's article is on DVD playback, and I'll be demonstrating four applications from the ports collection which can be used for this purpose. Since I'll be elaborating on information found in the handbook, you'll want to read through that section as well.

There are two terms you should be aware of as they deal with DVD playback on a computer. The first is region codes. Nearly every DVD you purchase has a burnt-in region code indicating the distribution area for that DVD release. You'll find the DVD's region code on the rear jacket; it is usually towards the bottom next to the other symbols for Dolby Digital, the name of the studio, and the movie rating. Since movies are released at different times in different areas of the world, region codes are used to discourage the sale of DVDs before a region's official release date. Typically this isn't an issue unless, for example, you purchase a DVD while abroad only to discover you can't play it when you return home.

I'll list the region codes here since some of the DVD ports default to region code 1, meaning you may need to reconfigure the DVD application with the region code for your geographic area.

Region Code Geographic Area
1 Canada, US, US territories
2 Japan, Europe, South Africa, Middle East, Egypt
3 Southeast Asia, East Asia
4 Australia, New Zealand, Pacific Islands, Central America, Mexico, South America, Carribean
5 Russia, Indai, Pakistan, Africa (except Egypt), North Korea, Mongolia
6 China
7 Reserved
8 Airplanes, cruise ships

The other term is CSS, or the Content Scrambling System. Almost all DVDs (usually the ones with region codes) are encrypted to prevent users from creating illegal copies, meaning that in order to actually view the DVD, the hardware DVD player needs the necessary software to unscramble the DVD. This is where things get murky and downright ugly. Since this issue is still before the courts and I'm not a lawyer, I'll leave it to you to do your own research on the subject and decide whether or not you want to play encrypted DVDs on your computer. A Google search of "dvd css" will definitely give lots of food for thought. Again, not all DVDs are encrypted. When I went through my DVD collection, I discovered that about 75 percent of them were.

DVD playback on a computer is still an emerging science, meaning that your mileage will definitely vary depending upon your CPU, video card, and resolution settings. It is quite possible that your results will be very different than mine, so read the article with a grain of salt and leave yourself some time for experimentation. I would strongly suggest that both your version of FreeBSD and your ports collection be cvsupped to the latest sources and that you are using the latest version of XFree86. Also, ensure your system is optimized for DVD playback:

Step by step instructions for the above optimizations were given in the previous article.

Also, if you plan on tweaking any of the default settings that come with the DVD players, the following links are a great introduction to DVD terminology and how to navigate through the alphabet soup of input and output devices:

  • Xine HOWTO
  • MPlayer - The Movie Player for LINUX
  • The MPlayer site is highly recommended reading and is well worth devoting an evening to.

    Finally, become the superuser and create the following links:

    ln -s /dev/acd0c /dev/dvd
    ln -s /dev/racd0c /dev/rdvd

    One of the first things I discovered when I started playing DVDs on my computer is that most of my DVDs are scrambled by CSS, but a few aren't. As chance would have it, the very first DVD I tried playing just happened to not be scrambled. The second DVD I tried to play was encrypted, which left me wondering why something that had seemed so easy had suddenly become so difficult. As I demonstrate each port, I'll show the differences between playing an unencrypted and an encrypted DVD.

    There are four ports that deal with DVD playback: vlc, xine, mplayer, and ogle. My criteria for evaluating each port was, in order of importance:

    1. No choppiness in audio or video
    2. Works "out-of-the-box" without having to read tons of documentation
    3. Skinnable, nice-looking interface

    vlc

    Okay, enough prep. Let's start with the "vlc" port:

    cd /usr/ports/graphics/vlc 
    make install clean

    The executable will be installed to /usr/local/bin/vlc. While "vlc" isn't skinnable, it does have a decent enough looking interface which is very intuitive to use. Simply insert a DVD into your DVD drive, click on the Disc option in "vlc" and choose the Chapter you would like to start at.

    If you find when you play a DVD that you're only seeing the top two-thirds of the movie, your resolution is set too high. Press "ctrl alt -" (use the - on the Num Lock portion of the keyboard on the far right). This will allow you to scroll through your resolutions until you find the best one for playing DVDs.

    I found that the "out-of-the-box" vlc was choppy in the audio, and the audio lagged a second or two behind the video. Encrypted DVDs were worse and far too choppy to be listenable. There were tons of options in Settings -> Preferences that I could select. However, whenever I hovered over any of the select buttons, I received a message stating that the "default behaviour is to automatically select the best module available." So I didn't bother to change any of the defaults. And, according to the vlc FAQ, choppy audio is a known problem which is being investigated. For myself, I've placed vlc on the backburner, and I'll take another look at it in a few months time to see how things improve.

    xine

    Next, I tried xine:

    cd /usr/ports/graphics/xine		
    make install clean

    The xine application itself will only play unencrypted DVDs. However, there are plugins available for those who wish to play encrypted DVDs:

    /usr/ports/graphics/xine_d4d_plugin
    /usr/ports/graphics/xine_d5d_plugin

    There is also a plugin which supports DVD menu features:

    /usr/ports/graphics/xine_dvdnav_plugin 

    I built all four ports in order to test them. The xine application will be installed to /usr/X11R6/bin/xine and any installed plugins will show as buttons in the xine GUI. This GUI is skinnable with skins available at xine.sourceforge.net. If you find a skin you like:

    cd ~/.xine
    mkdir skins

    Then, download the skin to your skins directory. The xine skins were a real strain on my sanity. Each skin moved the buttons to a different place, renamed the buttons to something else, and changed the configuration options. Some of the skins were non-intuitive. I had no idea what would happen if I pressed a certain button. Sometimes I ended up with an "xine engine error" message which refused to go away until I killed xine.

    Trying to play DVDs turned into an even more frustrating experience. Sometimes, clicking on the DVD button, then the play button, would start playing an unencrypted DVD. Sometimes, clicking on the MRL browser button, then clicking on its DVD button, then clicking on play did it. Sometimes I clicked all over, waited forever, and only froze up the GUI.

    I had better luck with the NAV button which gets installed with the dvdnav plugin. This gave the extra features of retrieving the name of the DVD and allowing the mouse to choose a menu selection. Without this plugin, I had a rough time figuring out which of the buttons would get me past the main menu and into the movie.

    Playing unencrypted DVDs with xine gave me the opposite problem that vlc had: the audio was decent but the video was slightly choppy and not always matched up to the audio.

    In order to play an encrypted DVD, I had to use either the D4D or D5D button. If I tried the DVD button, I received that "xine engine error" which was my clue that I had discovered an encrypted DVD. I was unable to convince the D4D button to do anything other than seg-fault. D5D took a couple of minutes to decrypt the keys. The resulting video was gorgeous. I had forgotten how much better the resolution is on a monitor compared to a TV. Audio varied from perfect to choppy, so I almost threw the PC out the window. I think I will wait a bit to allow the plugins to mature before trying xine again.

    MPlayer

    Next, I tried MPlayer. This port comes with a lot of options, but most of them are already enabled or are auto-detected for you. However, you do have to specify the following options in order to enable them:

    WITH_GUI	#builds the GUI	
    WITH_LIVE	#enables live.com streaming media support
    WITH_TDFXFB	#enables Voodoo 3/banshee support

    I don't have a Voodoo video card and I wasn't interested in live.com support, so I just specified the GUI option like so:

    cd /usr/ports/graphics/mplayer
    make WITH_GUI=yes install clean

    I could have also used this alternative method to specify the make option:

    make -DWITH_GUI install clean

    Once the install was finished, I exited the superuser account but stayed in the same directory. Now, as my regular user I ran this command:

    make install-user

    Since I built the GUI, I use the executable /usr/local/bin/gmplayer. If you don't use the GUI, use /usr/local/bin/mplayer instead.

    The Mplayer GUI is skinnable, so I also built the skins:

    cd /usr/ports/graphics/mplayer-skins
    make install clean

    I was prompted to select which skins to install. I chose to install them all. The first time I started MPlayer, I was really impressed with the interface. This is what a DVD player should look like, and the skins blow the other DVD players out of the water.

    A right-click anywhere on the GUI allowed me to change skins, set Preferences, and open a DVD disc. I thought, great, I've found an intuitive and gorgeous interface. Unfortunately, my enthusiasm was short-lived.

    I started with a non-encrypted disc which began playing with crisp video and clear audio. After about 20 seconds, a very large error message informed me that my system was too slow. Curbing my irritation at such a blatant presumption, I dutifully stopped the DVD, recorded the error message's suggestions, and implemented the suggested changes. The changes worsened the situation: now both audio and video were choppy and still accompanied by the same error message.

    Not to be deterred, I started to systematically change one thing at a time in the Preferences. I discovered the joys of no sound, choppy sound, and perfect sound for a maximum of 2 minutes. After exhausting all of those changes, I was faced with trying combinations of changes. At that point, I went in search of documentation. Of that, there was no shortage. There is a very comprehensive "man mplayer" and an even larger /usr/local/share/doc/mplayer/documentation.html. At some point in my reading, it became obvious that I was doing too much work just to play a DVD.

    As a last-ditch effort, I tried just using MPlayer on the off-chance that it was the GUI that didn't agree with my system:

    mplayer -dvd 1

    Same deal. Only difference was that the irritating error message quietly stayed in the xterm instead of popping up in front of the movie. So I sadly waved goodbye to that gorgeous GUI and placed Mplayer in my list of things to try again at a later date.

    ogle

    Finally, I tried ogle. By default, ogle's engine is command-line based, but there is a port that will also build a simple GUI:

    cd /usr/ports/graphics/ogle-gui
    make install clean

    The executable will be installed to /usr/local/bin/ogle. The interface isn't anything to write home about, but it is clean and intuitive. To play a DVD, go to the File menu -> Open disc. The ogle port automatically installs support for menus so you can use your mouse to select the desired menu option once the movie starts.

    I started with an unencrypted disc, and to my surprise, gorgeous video was perfectly matched to crystal clear audio. No blips, no chop. Hardly believing my good fortune, I pushed my luck with an encrypted DVD. I had to wait a few minutes for the decryption process, but there it was: I had attained perfect playback. Just when I had almost given up on ever watching a DVD again. The ogle port had matched my first two criteria: no choppiness out-of-the-box without reading manpages or tweaking properties sheets, just a play button. In fact, I don't know if it's a bug or a feature, but when you press Edit -> Properties in ogle, nothing happens. The only thing missing is some good looking skins.

    Well, those were the results of my adventures and misadventures with DVD playback. I know I promised in the last article to also cover RealPlayer and some other miscellaneous ports, but the DVD section turned out to be longer than I expected. These will be the subject of the next article.

    Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.


    Read more FreeBSD Basics columns.

    Return to the BSD DevCenter.


    Copyright © 2009 O'Reilly Media, Inc.