Wednesday, December 5, 2007

How to Overcome multimedia hurdles in Linux

For many, one of the biggest hurdles preventing them from adopting Linux is the difficulties that arise when it comes to dealing with multimedia. In most cases, the Linux multimedia experience is still not like Windows or OS X, where you can click on a file and the player just opens and plays the video or audio clip. In the Linux world, you need to ensure the proper software is installed. When everything is in the right place, the magic will happen.

What's the problem?
Unfortunately, getting the magic to happen isn't always as simple as we'd like it to be, but it's not impossible. In some instances with certain players, getting files such as WMV files is quite simple. In others, however, it can be a nightmare. However, even the nightmare has come a long way from the days of trying to get Windows Media Player to work with Wine. Now it's as simple as getting MPlayer or Totem to work with the correct codecs (devices that enable either the encoding or decoding of a digital signal). It is with these codecs that Linux is given the ability to play audio and video files; they are not typically installed by default, so the codecs enable Linux to play files that were historically only playable with the Windows Media Player (or another Windows equivalent).

Before we get into codecs, I'll introduce the major players in the Linux multimedia party.

MPlayer

MPlayer (Graphic Minimalistic Player) is one of the more popular -- but not the best -- media players for Linux. MPlayer has been around for a while; near the beginning of its existence, it looked as if it was destined to be the standard for Linux multimedia.

However, something happened along the way, and the bugs started flying on an apocalyptic scale. Like all good open source applications, the bugs were squashed; but unfortunately by this time, better players had popped up on the market (more on these later). MPlayer isn't worthless; I still use MPlayer for many files. For me, it's been easier to resolve many problems with MPlayer than with other applications.

Installing MPlayer is simple: on a yum-based system, run the command (as root) yum install gmplayer; on an apt-get based system, run the command apt-get install gmplayer. Once MPlayer is installed, you can run the player either from the Sound And Video menu (GNOME start menu), or from the KDE Multimedia entry in the start menu. Once the player is open, you'll see something similar to Figure

The out-of-the-box MPlayer GUI is certainly user friendly.

There's very little to explain about MPlayer that the average user won't be able to figure out. There are, however, some things to note. First, ensure that you're using the correct audio and video drivers. Figure shows the configuration screen for the video drivers.

You'll configure everything you need for MPlayer from this window.

The video driver you use must work with the drivers installed for your video card. If you don't have a gl-compatible video card (or a lower-end card) and you select a gl-based driver, your machine could come to a screeching halt. If you're not sure which driver you're using, take a look at your xorg.conf file (as root) and check the "Device" section; this will look similar to:

Section "Device"

Identifier "Videocard0"

Driver "nvidia"

Option "HWcursor" "false"

The line to look for is the Driver line. In my case, I'm obviously using the nvidia driver. Another thing to notice in the xorg.conf file is the presence of the glx -- or GLCore --modules in the Modules section. If there are no lines in the Modules section to load the gl-related modules, then using a gl-based driver would be a bad idea. Instead, stick with the safer xv default.

A configuration in MPlayer that always bothers me is that the video window shows even when there's nothing playing, leaving an extra window open. From within the Misc tab of the MPlayer configuration window, you can deselect this option. Another small issue: When you change a configuration, you have to restart MPlayer for the configuration to save.

VLC
VLC (VideoLan Client) is quickly becoming one of the most popular Linux video playback applications. (Note: Of all the multimedia applications I have used, VLC is by far the best.) VLC is a cross-platform system; there are binaries for Linux, Windows, and OS X. VLC supports a huge amount of file formats; probably the most of any player, no matter the platform.

Installing VLC is as simple as any other applications. With a yum-based distribution, run the command yum install vlc and with an apt-based distribution run the command apt-get install vlc. Both package managers will pick up the dependencies and install the system.

Running VLC can be done from either from the command line by running the command vlc or from the KDE Multimedia menu or from the GNOME Sound And Video menu. When you run VLC, you'll only see a small window, shown in Figure, from which you do everything.

To open a file, press the button that would normally serve as the Eject button.

A nice feature with VLC is that the equalizer actually works and works real time. To open the equalizer, press the Equalizer button on the main VLC window, as shown in Figure.

The EQ button is easy to miss.

Once the EQ is open, you first have to enable it by pressing the Equalizer Status button. You'll see this in Figure.

You know it's on if the buttons are glowing blue.

Simply move the sliders associated with the frequency you want to change.

VLC is also outstanding at playing music. You can create playlists by opening the playlist window, adding files, and saving the playlist (you can also do this with video). VLC can also serve as a DVD player as well.

XMMS

For a long time, XMMS reigned as the king of MP3 players on Linux. Known as Winamp on the Windows platform, this player was (and is) an outstanding means for playing various file formats.

However, once the MP3 file format became restricted, no Linux distribution would ship with MP3 support included. So if you want to play MP3 files on your Linux distribution, you'll have to roll in support for it. To do this for XMMS, follow the subsequent steps.

With a yum-based distribution (as root), run the commands:

yum install xmms-mp3

This should get the matching xmms-mp3 file for your already-installed XMMS installation. If it complains that the files aren't the same, remove it with yum remove xmms, and then run the command:

yum install xmms xmms-mp3

You should now be good to go.

With apt-get, you should be able to do this with the command:

apt-get

install xmms xmms-mp3

The XMMS application should be self-explanatory.

Totem
Totem is the default multimedia player with any GNOME-based distribution; this is an issue for many, since Totem seems to wince at playing nearly anything. Even with all the codecs in place, Totem can not play popular file formats, such as WMV files. That's too bad, because Totem is actually quite a good player. However, with the installation of a simple plug-in, you can at least get Totem to play MP3 files. To do this, issue (as root) the command:

yum install gstreamer-plugins-ugly

or

apt-get install gstreamer-plugins-ugly

I've only managed to get Totem to read WMV files on an Ubuntu 7.10 installation. By installing the codecs as you would for any of the players, it works, but only on Ubuntu. I have had no luck with Fedora.

Codecs
There are a number of files that need to be installed for this method; after all, we're installing files to help support different file formats for numerous players. However, this process has been made simple by standardization.

In order to get the necessary codecs, visit the MPlayer site and download the binary codec package. The file will be in a BZ2 format, so you'll have to run the following command:

bunzip2 essential-XXX.tar.bz2

where XXX is the actual release number.

Now unpack the file with:

tar xvf essential-XXX.tar

where XXX is the actual release number.

Now cd into the newly created directory and, as root, issue the command:

cp * /usr/lib/codecs/

Now your multimedia players will support the once-dreaded WMV format in Linux.

What about Firefox?
Getting multimedia support in Firefox really isn't difficult. If you visit the Common Plugins for Firefox page, you'll see all the necessary plug-ins (along with installation documentation).

Command-line players
I would be remiss if I didn't at least mention that there are numerous command-line players for multimedia. Let's visit the short list:
  1. mplayer: The command-line version of MPlayer (the GUI command is actually gmplayer). To open a media file with this command, simply run mplayer FILE_NAME. If the file is a video, a new window will open with only the video playing. If the file is an audio file, no other window will open. This command is helpful if you need it to be executed in the background by another application.
  2. mpg123: This application is quite useful; it can play as well as convert audio files. If you want to create a playable CD from a collection of MP3 files, you can issue the command mpg123 -w FILENAME.wav FILENAME.mp3, and the resulting WAV file is ready for you.
  3. play: The play command allows you to play WAV and MIDI files in the background. Like mplayer, play is useful for running sounds in the background. I have used play in conjunction with Procmail to play various sounds for different incoming email, which is very handy.

At one time, it was thought that Linux would take a sideline to any other OS when multimedia is concerned, but times have changed: Linux is now a real player in the multimedia sector. Of course, that is not to say there aren't pitfalls: many times, I've come across a site that won't support Linux (even though the file format they stream is supported in Linux, i.e., abc.com).

I remember a time that getting all the necessary multimedia support up and running was a real chore. Now, out of the box, it's all there for you (with the exception of MP3 support, but that's another issue altogether).

If your issue with Linux is multimedia, it should be obvious that it's no longer a problem, so don't think twice about giving Linux a try.

2 comments:

Anonymous said...

Great post Paritosh. I use VLC on my Ubuntu machine and I love it.

Thanks for all the codec information. I may need it someday.

-Diana

---
I make a living with Forex investing
---

Anonymous said...

My friend and I were recently discussing about technology, and how integrated it has become to our daily lives. Reading this post makes me think back to that discussion we had, and just how inseparable from electronics we have all become.


I don't mean this in a bad way, of course! Societal concerns aside... I just hope that as technology further develops, the possibility of transferring our memories onto a digital medium becomes a true reality. It's one of the things I really wish I could see in my lifetime.


(Posted on Nintendo DS running [url=http://kwstar88.insanejournal.com/397.html]R4[/url] DS TF3)