Ubuntu and WMV support How-To

Either you like it or not, wmv (Windows Media Video) files are pretty common. You probably have a couple of those laying somewhere on your harddisk. The thing is that these video files play just fine on windows but are a bit tricky on Linux. Something similar apply for other media formats like videos encoded with divx or xvid. Anyway, i knew there was a way to achieve this so i started ‘googling’ and after a short research and alot of updating i can now enjoy my WMV files as also other video formats on my Ubuntu(breezy) laptop! The following how-to is for Gnome since its the only environment i am using.

So let’s start. First you need to update and upgrade Ubuntu to be sure you are running with the latest updates.

$ sudo apt-get update
$ sudo apt-get upgrade

(Tip. A quick workaround to avoid typing sudo for every command would be: “$ sudo bash”)

You then need to get all the required codecs to play WMV. Since WMV’s codecs are not free you must add an extra repository to your apt-get lists to download the needed codecs.

$ sudo pico /etc/apt/sources.list

and append the following line:

deb http://packages.freecontrib.org/ubuntu/plf/ breezy free non-free

Save the file and update again ($ sudo apt-get update)

Now you need to download every codec available to play all WMVs, since various versions exists. WMV3 are the tricky ones!

$ sudo apt-get install w32codecs
$ sudo apt-get install libdvdcss2 (in case you need DVD playback)

Now just to be sure get every other codec available from mplayer’s repository (essential codecs package)
$ wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20060501.tar.bz2

(You can always choose another mirror from www.mplayerhq.hu)
Note: Make sure you are using the latest codecs file. (essential-20060501.tar.bz2 may not be the latest)
Extract codecs and copy to /usr/local/lib/codecs
$ tar -xjf essential-20060501.tar.bz2
$ sudo mkdir /usr/local/lib/codecs (if it does not exists)
$ sudo cp essential-20060501/* /usr/local/lib/codecs/

Some other movie players look up their codecs in different directories such as /usr/lib/win32/. In this case where xine will be used /usr/local/lib/codecs will do just fine!

Now lets choose our player. I found xine (gxine) and it wokrs just fine and have everything i need. So install it if you haven’t already

$ sudo apt-get install gnome-xine
$ sudo apt-get install gxine

Now you are set. You can play WMV files with xine. To start xine

$ gxine

If you are a fanatic “double click” user you will find out that when you doubleclick on WMV files you will get the following message.

The filename “file.wmv” indicates that this file is of type “Microsoft WMV video”. The contents of the file indicate that the file is of type “Microsoft ASF video”. If you open this file, the file might present a security risk to your system.Do not open the file unless you created the file yourself, or received the file from a trusted source. To open the file, rename the file to the correct extension for “Microsoft ASF video”, then open the file normally. Alternatively, use the Open With menu to choose a specific application for the file.

This is a precaution Nautilous takes to avoid unsafe files to run based on their headers. A quick workaround is to rename your file from “file.wmv” to “file.WMV” (Thats capital “WMV”).
A more generic and complete approach will be, messing with Nautilus mimetypes. So to bypass the message above you simply have to say Nautilus that WMV are assosiated with gxine.

(Note you can choose a program to run the specific extension but still you won’t be able to use doubleclick)

Now, off with Nautilus mimetypes tweaking.
First edit the default lists of mimetypes

$ sudo pico /usr/share/applications/defaults.list

Find the lines about wmv that you wish to assign to gxine and edit them:
(Mine are the following)
video/x-ms-asf=gxine.desktop
video/x-msvideo=gxine.desktop
video/x-ms-wmv=gxine.desktop

The gxine.desktop is the application information that Nautilus will use.

Then make sure that gxine.desktop exist in /usr/share/applications/ and make sure it has the following line:
MimeType=video/mpeg;video/x-msvideo;video/quicktime;video/x-ms-asf;video/x-ms-wmv
(Basically only video/x-ms-wmv is needed but i’m again using a more complete list)

Finaly you need to edit the cache file
$ sudo pico /usr/share/applications/mimeinfo.cache

Look for wmv entries and edit them as before:
video/x-ms-wmv=gxine.desktop

And that’s all! Really this time (: Now you can even double click on your WMV files and gxime will load them automatically!

Update 13th of May: Updated some typos. Thanks guys (:

15 Responses to “Ubuntu and WMV support How-To”

  1. 1

    Nice tutorial man! Keep up the good work ;)

    April 6th, 2006 at 10:54 am
  2. 2

    BTW I am not sure but I believe that EasyUbuntu does the same thing, in an easier way :)

    April 6th, 2006 at 7:06 pm
  3. 3

    Thnx for the comments (:
    Am installing EasyUbuntu right now! Thnx for the tip !

    April 6th, 2006 at 8:51 pm
  4. 4

    So, you main Desktop OS is Ubuntu? not Mac OSX? or Windows?

    April 17th, 2006 at 5:24 pm
  5. 5

    Heh, well, my main desktop is Windows XP with a seperate disk having Mac OSX86 installed. My laptop is running Ubuntu 5.10. Hope this clears things up(:

    April 17th, 2006 at 5:29 pm
  6. 6

    Thanks for the tutorial.
    I believe that to install xine, the command should read “sudo apt-get install gnome-xine”.

    April 19th, 2006 at 7:50 pm
  7. 7

    Hey Michael,
    Thanks for letting me know about the typo! (:

    April 21st, 2006 at 2:10 pm
  8. 8

    The line:
    $ wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20050412.tar.bz2
    should be replaced with:
    $ wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20060501.tar.bz2

    Cheers for the tutorial!

    I’m having a bit of trouble with the audio playback, is this fixable?

    May 13th, 2006 at 11:00 am
  9. 9

    also… (append to previous comment)

    video/x-ms-asf=gxime.desktop

    gxine.desktop // not gxime.desktop :P

    May 13th, 2006 at 11:02 am
  10. 10

    Hey Neil,
    Thanks for the update. Audio playback shouldn’t be a problem at all. Audio Codecs are pretty much straight forward. Is this happening to all of your videos?

    May 13th, 2006 at 11:03 am
  11. 11

    or you could use automatix check the codecs box and be done with it

    June 30th, 2006 at 6:56 am
  12. 12

    essential-20060611.tar.bz2

    July 21st, 2006 at 6:51 pm
  13. 13

    Joaquim: as you know, its been a while since i wrote this article so the filenames, especially those containing dates, might be out of date. Thnx for your update though.

    Also as said on other comments, if you install automatix and EasyUbuntu you will get your wmv support + more with less hustle (:

    July 21st, 2006 at 6:56 pm
  14. 14

    thank you very mach..

    October 17th, 2006 at 6:05 pm
  15. 15

    its cool..

    October 18th, 2006 at 4:56 am

Leave a Reply