Adding Support for almost All Video Formats/Codecs in Linux

Written by BinnyVA on September 13, 2008 – 12:25 am -

Multimedia

There is an over abundance of video formats right now – fortunately, our favorite OS, Linux, is capable of handling all of them. But some video formats are not supported ‘out-of-the-box’ – in such cases, we have to install the necessary codecs. This guide will show you how install the codecs for just about every video format under the sun.

Before going into the topic further, let me pacify the flamers in the audience. There are many codecs that include DRM and many are proprietary – and for this reason, many distros refuse to support them. But these can be supported using external software – whether or not to do that is a choice I leave to the readers. I am only handling the technical issue of installing the codecs here. The moral and ethical concerns have been handled by others better than me.

The Players – Video Trinity

There is no shortage of video players in linux. Among these, three players are more prominent than the others – these are Mplayer, Xine and VLC. I call them the Video Trinity. Before doing anything, install all three players. Yes, all of them.

Mplayer

Mplayer is perharps the most popular among linux video players. You can install it in a Red Hat/Fedora system using this command(the command for debian/ubuntu systems will be similar – can someone post it in the comments?)…

yum install mplayer mplayer-fonts mplayer-gui

If you are on a Debian based system – like Ubuntu, use this command…

apt-get install mplayer mplayer-fonts mplayer-skins

Xine

xine is a free multimedia player. It plays back CDs, DVDs, and VCDs. It also decodes multimedia files like AVI, MOV, WMV, and MP3 from local disk drives, and displays multimedia streamed over the Internet. It interprets many of the most common multimedia formats available – and some of the most uncommon formats, too. Installing xine is just as easy…

yum install xine xine-lib xine-skins xine-lib-extras-nonfree 

Again, on a Debian/Ubuntu system, use the command…

apt-get install xine-ui

VLC

VLC media player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, …) as well as DVDs, VCDs, and various streaming protocols. VLC is popular in the windows crowd as well. Here is the command to install it…

yum install vlc

Debain/Ubuntu uses should use the command…

apt-get install vlc

With these 3 players installed, you must be able to open 90% of the video files out there. But for the more exotic video formats, we must install the extra codecs provided by mplayer. First install the codes available in your distro’s repository – in Fedora(with Livna repository) the command I used is…

yum install gstreamer libdvdcss gstreamer-plugins-ugly audacious-plugins-nonfree-mp3 kdemultimedia-extras-nonfree ...

Or in Debian/Ubuntu system

apt-get install gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-ffmpeg

Essential Video Codecs

The binary codec packages provided by mplayer adds support for codecs that are not yet supported natively, like newer RealVideo variants and a lot of rare formats. Note that they are not necessary to play most common formats like DVDs, MPEG-1/2/4, etc. Take a look at the codec status table for the list of currently supported codecs in Mplayer.

Instructions for installing binary codecs can be found in the README or in the README.txt file that accompanies each codec package. Detailed usage instructions are in the codecs section of the documentation. A brief overview of the installation procedure is given below...

Installing the Codecs

First, download the codecs package that matches your system. In most cases, that is Linux x86.

First, extract the file to a local directory. There should be 64 files(currently). Next, we have to copy this to the system's codecs folder(usually /usr/local/lib/codecs/). To do this, you must have root user privileges...

sudo cp -R essential-20071007/ /usr/local/lib/codecs/

Voila - we have installed the codecs. But we are not done yet. Some players look for the codecs in other folders - to accommodate those players, we have to link the other folders to the central codecs directory. To do that, run these commands(as root)...

ln -s /usr/local/lib/codecs/ /usr/lib/codecs
ln -s /usr/local/lib/codecs/ /usr/lib/win32
ln -s /usr/local/lib/codecs/ /usr/local/lib/win32

Playing the Video

Now open up the video you are trying to play in any video player(say mplayer) - in 99% of the cases, it will play without any issues. In the unlikely event of a problem, open up the same video in xine. If it still does not play, go to vlc. Your video will be working in atleast one of these three players.

Did it work for you - let me know in the comments...


del.icio.us | Digg it | reddit | StumbleUpon

Tags: , , , , , ,
Posted in Configuration, Troubleshooting, Video | 14 Comments »

14 Comments to “Adding Support for almost All Video Formats/Codecs in Linux”

  1. nongeek says:

    Glad to see you back on business Vinny! Great post! I like the idea of the Video Trinity. Why didn’t I thought of that? :p

  2. nongeek says:

    Pls change Vinny in Binny and erase this short message. Sorry for the tipo, but v is just before b on the keyboard. I was in a hurry.

  3. BinnyVA says:

    @nongeek
    Thanks – and dont worry about the typo – I have seen worse spellings for my name 😉

  4. Oliver says:

    Install MPlayer in Ubuntu:
    apt-get install mplayer mplayer-fonts gnome-mplayer

    Install MPlayer in Kubuntu:
    apt-get install mplayer mplayer-fonts kmplayer

    Thanks for your post, Binny!

  5. What is? says:

    How about adding support for the AMR and 3GP files from cellular phones?

  6. […] have used a lot of video players on Linux – and over the time my favorite video player have changed. When I wrote the post Top 5 Video […]

  7. michael says:

    So after reading your so wonderfull article – I am still wondering how one would get codecs into mplayer in ubuntu.

    Guess I will just keep wondering.

    Thanks a bunch.

  8. michael says:

    why don’t you tell the 1000 new linux users how to deal with tarballs.

  9. phil says:

    well on ubuntu 8.10 i just went to add/remove installed
    “movie player totem (xine backend)”
    and it all started working :)
    Hope that helps anyone

  10. Dotan Cohen says:

    AMR support, please! All the new phones record in this format.

  11. tad says:

    I had the following problem installing zine, it asked me to install yum which I did and then got the message at the bottom -I don’t know any code so simple suggestions only please!

    tad@tad-desktop:~$ yum install xine xine-lib xine-skins xine-lib-extras-nonfree
    The program ‘yum’ is currently not installed. You can install it by typing:
    sudo apt-get install yum
    bash: yum: command not found
    tad@tad-desktop:~$ sudo apt-get install yum
    [sudo] password for tad:
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    The following extra packages will be installed:
    libbeecrypt6 librpm4.4 python-celementtree python-elementtree python-rpm
    python-urlgrabber rpm
    Suggested packages:
    python-celementtree-dbg python-elementtree-doc alien
    Recommended packages:
    python-sqlite
    The following NEW packages will be installed
    libbeecrypt6 librpm4.4 python-celementtree python-elementtree python-rpm
    python-urlgrabber rpm yum
    0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
    Need to get 2422kB of archives.
    After this operation, 8913kB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get: 1 http://gb.archive.ubuntu.com hardy/main libbeecrypt6 4.1.2-6build1 [108kB]
    Get: 2 http://gb.archive.ubuntu.com hardy/main librpm4.4 4.4.2.1-1ubuntu6 [953kB]
    Get: 3 http://gb.archive.ubuntu.com hardy/universe python-elementtree 1.2.6-11ubuntu1 [30.4kB]
    Get: 4 http://gb.archive.ubuntu.com hardy/universe python-celementtree 1.0.5-9 [23.6kB]
    Get: 5 http://gb.archive.ubuntu.com hardy/main python-urlgrabber 3.1.0-4 [56.6kB]
    Get: 6 http://gb.archive.ubuntu.com hardy/main rpm 4.4.2.1-1ubuntu6 [625kB]
    Get: 7 http://gb.archive.ubuntu.com hardy/universe python-rpm 4.4.2.1-1ubuntu6 [422kB]
    Get: 8 http://gb.archive.ubuntu.com hardy/universe yum 2.4.0-3.1 [202kB]
    Fetched 2422kB in 2s (1098kB/s)
    Selecting previously deselected package libbeecrypt6.
    (Reading database … 118759 files and directories currently installed.)
    Unpacking libbeecrypt6 (from …/libbeecrypt6_4.1.2-6build1_i386.deb) …
    Selecting previously deselected package librpm4.4.
    Unpacking librpm4.4 (from …/librpm4.4_4.4.2.1-1ubuntu6_i386.deb) …
    Selecting previously deselected package python-elementtree.
    Unpacking python-elementtree (from …/python-elementtree_1.2.6-11ubuntu1_all.deb) …
    Selecting previously deselected package python-celementtree.
    Unpacking python-celementtree (from …/python-celementtree_1.0.5-9_i386.deb) …
    Selecting previously deselected package python-urlgrabber.
    Unpacking python-urlgrabber (from …/python-urlgrabber_3.1.0-4_all.deb) …
    Selecting previously deselected package rpm.
    Unpacking rpm (from …/rpm_4.4.2.1-1ubuntu6_i386.deb) …
    Selecting previously deselected package python-rpm.
    Unpacking python-rpm (from …/python-rpm_4.4.2.1-1ubuntu6_i386.deb) …
    Selecting previously deselected package yum.
    Unpacking yum (from …/archives/yum_2.4.0-3.1_all.deb) …
    Setting up libbeecrypt6 (4.1.2-6build1) …

    Setting up librpm4.4 (4.4.2.1-1ubuntu6) …

    Setting up python-elementtree (1.2.6-11ubuntu1) …

    Setting up python-celementtree (1.0.5-9) …
    Setting up python-urlgrabber (3.1.0-4) …

    Setting up rpm (4.4.2.1-1ubuntu6) …

    Setting up python-rpm (4.4.2.1-1ubuntu6) …

    Setting up yum (2.4.0-3.1) …
    /var/lib/python-support/python2.5/yum/__init__.py:1129: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /var/lib/python-support/python2.5/yum/depsolve.py:73: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /var/lib/python-support/python2.5/yum/repos.py:236: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /var/lib/python-support/python2.5/yum/repos.py:260: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /var/lib/python-support/python2.5/yum/repos.py:263: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /usr/share/yum-cli/cli.py:614: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /usr/share/yum-cli/cli.py:615: Warning: ‘with’ will become a reserved keyword in Python 2.6
    /usr/share/yum-cli/cli.py:616: Warning: ‘with’ will become a reserved keyword in Python 2.6

    Processing triggers for libc6 …
    ldconfig deferred processing now taking place
    tad@tad-desktop:~$ yum install xine xine-lib xine-skins xine-lib-extras-nonfree
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

    No module named cElementTree

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    It’s possible that the above module doesn’t match the
    current version of Python, which is:
    2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]

    If you cannot solve this problem yourself, please send this
    message to .

    tad@tad-desktop:~$

  12. BinnyVA says:

    @tad
    You don’t have to use Yum – that’s for Red Hat based systems. You are using a Debian based system – so you can do…
    sudo apt-get install xine-ui

  13. […] I hate it when that happens. Plus, there are other things I call Trinity. No, not The Trinity. I’m talking about video players. […]

  14. Van says:

    None of mplayer, xine, or vlc are available at the repositories that support CentOS. So yum didn’t install any of them.

Leave a Comment