Playing Video


Video recording (encoding) and playback (decoding) remain among the most contentious areas of potential litigation in open source software. On one hand you have patent holders of complex video formats that might ask for royalties for open source codecs (even when the software was written from scratch). On the other, you have the movie industry that has taken aim at those publishing what they had hoped were secret encryption techniques (DeCSS), to prevent the open source decoding of commercial movies. The problem is that the same technique that allows you to play movies in Linux also can be used to copy and share them.

Note 

Codec stands for COder /Decoder or COmpressor/DECompressor, depending on whom you ask. In either case, codecs are what make it possible to process and encode audio and video on computers.

As with audio recording, if you are starting from scratch, there is an open source codec called Theora ( www.theora.org ) you can use without paying any royalties, as of this writing. Provided you own the content you are recording, you can freely distribute that content as well and allow others to play it back.

When it comes to including video codecs (other than the free Theora), Red Hat, Inc. has taken the cautious approach. While Fedora and RHEL now include video players such as Totem (described later in this chapter), they do not include players (such as the MPlayer and Xine media players) that often are packaged with contentious codecs. If you want to play commercial movies, popular video clips, or other video content in a Red Hat Linux system, you have to get those codecs elsewhere.

This section describes some of the issues surrounding playing and creating video in Linux. It also describes video players that come with Fedora and RHEL, as well as those you can obtain to play a wide variety of video content.

Warning 

Video players, as well as other software, that are not included in the Fedora Core or Red Hat Enterprise Linux distributions may not have gone through the rigorous testing that other software distributed by Red Hat, Inc. has undergone. In particular, compatibility issues may arise when you mix multi-package applications, such as mplayer and xine, from different software respositories outside of Fedora and Fedora Extras. See Chapter 5 for information on dealing with multiple software repositories in Fedora and RHEL.

Examining Laws Affecting Video and Linux

We need to start out by reminding everyone that I am not a lawyer, so you need to take responsibility yourself regarding any software you put on your computers. However, there are several themes that have arisen in regard to playing video content with open source software in Linux:

  • Licensing fees for patented codecs may be required. While many video codecs are covered by patents, some patent holders don't charge for personal use. However, you should check current policies of companies who own patents on codecs you plan to use, as the terms of use are constantly changing. For example, this statement that was once posted on the DivX Web site is no longer there: "Personal use of DivX video software is free. Commercial use is not and requires that you obtain a commercial use license from DivXNetworks." (Refer to the DivX Web site www.divx.com for information on DivX licensing).

    Because MPEG-2 and MPEG-4 video formats are covered by a variety of patents, groups of patent holders have joined together to charge licensing fees for related encoders and decoders. These efforts are not sponsored by standards organizations that spearheaded the creation of those formats and may not cover every patent holder related to the software you are paying for. See the MPEG Industry Forum for details on MPEG patent issues ( www.m4if.org/patents ).

  • Unauthorized copying of copyright-protected material is never legal. Even legal video codecs do not make it legal to copy commercial movies and other protected content and distribute them to others. There are questions as to whether or not, for example, it is legal to make a personal back-up copy of a DVD movie (a commonly accepted legal practice with computer software). But any redistribution of movie, music, or other media content is not legal without the owner's permission.

Because patenting eliminates trade secret protection for the subject matter disclosed in the patent (or published patent application), many people have raised the question of why someone can't freely distribute libdvdcss (based on DeCSS decryption) to play DVD movies. Without copyright or patent coverage on CSS, it should not be illegal to distribute libdvdcss and there's nobody to pay a license fee to for using it. In regards to libdvdcss, another issue arose in the United States: the Digital Millennium Copyright Act (DMCA). DMCA might make DeCSS illegal because the technology is used to break an encryption scheme to circumvent copyrighted material.

As for the software patent issues, those are being fought on several fronts besides those relating to multimedia content. As noted earlier, the contention held by many open source proponents is that software should be copyrighted and not patented (see the section "Understanding Multimedia and Legal Issues in Linux" earlier in this chapter.)

With all that said, the next parts of this chapter go on to describe which players are available to play a wide range of video content in Linux. It is up to you to work out the maze of which codecs are free for you to use and in what ways.

Understanding Video Content Types

Before launching into the video players themselves , I want to try to clear up a bit of confusion relating to video file formats and codecs.

  • Video file formats - A video file format essentially describes the structure of a video file for combining audio and video content. That structure can also define such things as subtitles and how audio and video are synchronized. However, a variety of video and audio codecs may have been used to encode that content. So, just because you can play a video file that is marked as MPEG ( .mpg ), Audio Video Interleaved ( .avi ), QuickTime ( .mov ), RealMedia ( .rm ), Windows media ( .wvm ), Advanced Streaming Format ( .asf ), or other file format, it doesn't mean that you can play all video files marked as such.

  • Video and audio codecs - Codecs are used to encode and decode video and audio content. A video encoded entirely with free software might use Theora to encode the video and Ogg Vorbis to encode the audio. Popular video codecs include MPEG-4, DivX, Xvid, RealVideo, and MJPEG.

Not all video codecs and file formats are suitable for streaming video. For example, AVI and MPEG-2 are not streamable. However, RealMedia, MPEG-4, and ASF format can be streamed. Check the descriptions of video players in the following sections for information on which players can support which codecs.

If you have a video file on your hard disk and you'd like to know what type of content it contains, you can use the file command. Here's an example of the file command for checking the contents of a movie trailer:

 $  file movie.avi  movie.avi: RIFF (little-endian) data, AVI, 640 x 272, 23.98 fps, video: DivX 3, audio: MPEG-1 Layer 3 (stereo, 44100 Hz) 

This example shows that the file contains DivX 3 video and MPEG-1 Layer 3 audio. The size of the video is 640 x 272 pixels. Video was captured at 23.98 frames per second. This can lead you to the type of video player you need to play the content. Given that the right codecs are installed, MPlayer, Xine, VLC, or several other players would be able to play this content.

Watching Video with Xine

At the base of the Xine video player ( http://xinehq.de ) is the xine-lib core engine. While Xine has its own xlib-based user interface, you can choose different video player front-ends to use with the core engine instead (including Totem, Kaffeine, and aaxine). You can also use Xine as a Mozilla plugin, to have videos play in a browser window.

The xine player is an excellent application for playing a variety of video and audio formats. You can get xine from http://xinehq.de (which takes some work to get going) or by downloading RPMs from rpm.livna.org/fedora . (See Chapter 5 for information on using Livna.org and other software repositories for getting Fedora and RHEL software. If yum is configured to point to one of those repositories, you should be able to install Xine by typing yum install xine ).

Note 

The Xine project offers the following disclaimer before you download or use its software: Some parts of xine ( especially audio/video codecs) may be subject to patent royalities in some countries . If you provide pre-compiled binaries or intend to build derivative works based on the xine source please consider this issue. The xine project is not warranting or indemnifying you in any way for patent royalities. You are solely responsible for your own actions.

You can start the xine player by typing xine& from a Terminal window. Figure 8-12 shows an example of the xine video player window and controls.

image from book
Figure 8-12: Play video CDs, MP3s, QuickTime, and other video formats with xine.

The xine setup window (shown to the right) lets you choose various settings for the video player, such as a different user interface, if one is available. Below the Xine window is the Xine controller, which has buttons that work like many physical DVD players. Right-click the main window to see a menu of options. Select Settings Video to display another controller (shown at the bottom of Figure 8-12) that lets you adjust hue, saturation, brightness, and contrast.

Xine supports a bunch of video and audio file formats and codecs. However, not all of these codecs are distributed with xine:

  • MPEG (1, 2, and 4)

  • QuickTime (see "Xine tips" if this content won't play)

  • RealMedia (see "Xine tips" if this content won't play)

  • WMV (see "Xine tips" if this content won't play)

  • Motion JPEG

  • MPEG audio (MP3)

  • AC3 and Dolby Digital audio

  • DTS audio

  • Ogg Vorbis audio

Using the Xine controller, you can select to play content directly from a DVD, DVB, VCD, VCDO, or CD disk. If you are playing an audio CD (or any audio file), you can choose different visualizations (right-click, and then choose Audio Visualization and select goom, oscope, fftscope, or fftgraph) to appear in the xine windows as music plays.

Xine can understand different file formats that represent streaming audio and video. These include .mpg (MPEG program streams), .ts (MPEG transport streams), .mpv (raw MPEG audio/video streams), .avi (MS AVI format), and .asf (Advanced Streaming format). While xine can play video CDs and DVDs containing other content, it can't play encrypted DVDs or video-on-CD hybrid format without adding other software (because of the legal issues mentioned earlier related to decrypting DVDs).

Using xine

With xine started, right-click in the xine window to see the controls. The quickest way to play video is to click one of the following buttons, and then press the Play button (right arrow or Play, depending on the skin you are using):

  • VCD (looks for a video CD)

  • DVD (looks for a DVD in /dev/dvd )

  • CDA (looks a music CD in /dev/cdaudio )

Next, you can use the Pause/Resume, Stop, Play, Fast motion, Slow motion, or Eject buttons to work with video. You can also use the Previous and Next buttons to step to different tracks. The controls are very similar to what you would expect on a physical CD or DVD player.

To select individual files, or to put together your own list of content to play, you can use the Playlist feature.

Creating Playlists with xine

Click the Playlist button on the left side of the xine control window. A Playlist Editor appears, showing the files on your current playlist. You can add and delete content from this list, and then save the list to call on later. Here's how you use the xine Playlist Editor:

  • CDA, DVD, or VCD - Click any of the buttons that represent a particular CD or DVD. All content from that CD or DVD is added to the playlist.

  • Add - Click the Add button to see the MRL Browser window. From that window, click File to choose a file from your Linux file system to add to the list. Click Select to add that file to the Playlist Editor.

  • Move up/Move down - Use the Move up selected MRL and Move down selected MRL buttons to move up and down the playlist.

  • Delete - Click the Delete Selected MRL button to remove the current selection.

  • Delete all - Click the Delete All Entries button to clear the whole playlist.

  • Save - Click the Save button to save the playlist to your home directory ( $HOME/.xine/playlist.tox or give it another name ).

  • Load - To read in the playlist you saved, click the Load button.

The xine content is identified as media resource locators (MRLs). Each MRL is identified as a file, DVD, or VCD. Files are in the regular file path ( /path/file ) or preceded by file:/, fifo:/ , or stdin:/ . DVDs and VCD are preceded by dvd and vcd , respectively (for example, vcd://01) .

To play your playlist, click the Play button (arrow key) on the Playlist Editor.

Xine Tips

Getting video and audio to work properly can sometimes be a tricky business. Here are a few quick tips to using xine:

  • Xine won't start. To work best, xine needs an X driver that supports xvid. If there is no xvid support for your video card in X, xine will shut down immediately when it tries to open the default Xv driver. If this happens to you, try starting xine with the X11 video driver (which is slower, but should work) as follows :

     $  xine -V XShm  
  • Don't run as root. Run xine as a regular user, instead of as root. Once xine is installed, you should be able to run it from the Applications menu on your panel by selecting Sound & Video Xine Media Player. There have been recently discovered vulnerabilities of some open source media players related to streaming media. Though that problem was fixed, it again highlighted the fact that running applications as a regular user, whenever possible, is a good idea.

  • Run xine-check. To get an idea of how happy xine is running on your system, run the xine-check command (as the user who will be using xine). It will tell you if there are problems running xine on your current operating system, kernel, and processor, among other things.

  • Xine playback is choppy. If playback of files from your hard disk is choppy, there are a couple of settings you can check: 32-bit IO and DMA. (If these two features are supported by your hard disk, they will generally improve hard disk performance.)

Caution 

Improper disk settings can result in destroyed data on your hard disk. Do this procedure at your own risk. This procedure is only for IDE hard drives (not SCSI)! Also, be sure to have a current backup and no activity on your hard disk if you change DMA or IO settings as described here.

First, test the speed of hard disk reads. To test the first IDE drive ( /dev/hda ), type:

 #  hdparm -t /dev/hda  Timing buffered disk reads: 64 MB in 19.31 seconds = 3.31 MB/sec 

To see your current DMA and IO settings, as root user type:

 #  hdparm -c -d /dev/hda  /dev/hda: I/O support = 0 (default 16-bit) using_dma = 0 (off) 

This shows that both 32-bit IO and DMA are off. To turn them on, type:

 #  hdparm -c 1 -d 1 /dev/hda  /dev/hda: I/O support = 1 (32-bit) using_dma = 1 (on) 

With both settings on, test the disk again:

 #  hdparm -t /dev/hda  Timing buffered disk reads: 64 MB in 2.2 seconds = 28.83 MB/sec 

As you can see from this example, buffered disk reads of 64MB went from 19.31 seconds to 2.2 seconds after changing the parameters described. Playback should be much better now.

  • Xine won't play particular media. Messages such as no input plug-in mean that either the file format you are trying to play is not supported or it requires an additional plug-in (as is the case with playing DVDs). If the message is maybe xyx is a broken file , the file may be a proprietary version of an otherwise supported format. For example, I had a QuickTime video fail that required an SVQ3 codec (which is currently not supported under Linux), although other QuickTime files will play fine.

    If a particular multimedia format is not supported, but you have Windows dlls available that support it, you can add those dll files to the /usr/lib/win32 directory. Some of these codec ddls are available from www.mplayerhq.hu/homepage/dload.html in a package called essential .

Note 

The CrossOver Plugin (described in Chapter 9) can be used to play a variety of content, including the version of QuickTime just mentioned.

Using Totem Movie Player

The Totem movie player ( www.gnome.org/projects/totem ) comes with the GNOME desktop environment. In Fedora and RHEL, Totem can play video in Theora format with Ogg Vorbis audio. Totem is based on GStreamer ( http://gstreamer.freedesktop.org ), so it can be used with other video software from that project that is still in early stages of development.

Totem also supports a xine backend that allows it to play a wide range of video content (in other words, anything xine supports). The Totem project page offers a link to Fedora RPMs for xine-ui and libxine1 ( http://cambuca.ldhs.cetuc.puc-rio.br/xine ) that are built daily, which can be used to provide xine functionality (provided the software is legal where you live).

Besides common controls you would expect with a movie player (play, pause, skip forward, skip backwards , and so on), Totem lets you create playlists, take a snapshot of the current frame, and adjust the volume. You can change preferences, which let you add proprietary plug-ins, select your DVD device, and balance color . Figure 8-13 shows an example of the Totem window.

image from book
Figure 8-13: Totem plays Theora video, plus any codecs supported by Xine and GStreamer.



Fedora 6 and Red Hat Enterprise Linux Bible
Fedora 6 and Red Hat Enterprise Linux Bible
ISBN: 047008278X
EAN: 2147483647
Year: 2007
Pages: 279

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