How to play restricted formats with Ubuntu (multimedia codecs)

Prerequisites: add universe and multiverse repositories.

What are restricted formats?

These are non-Free formats and tools, well-known from the Win32 world. The most important ones are Java, MP3, Windows Media, Real Media, RealPlayer, DVD-video, Macromedia Flash, AAC and iTunes Music Store and some other Video and Audio Codecs.
All of them are not included within the Ubuntu standard installation. You have to install them manually.

How to install the restricted formats?

You can install the codecs with the following commands:
sudo apt-get install gstreamer0.8-plugins
sudo apt-get install gstreamer0.8-lame
sudo apt-get install gstreamer0.8-ffmpeg
sudo apt-get install w32codecs
sudo apt-get install libdivx4linux
sudo apt-get install lame
sudo apt-get install sox
sudo apt-get install ffmpeg
sudo apt-get install mjpegtools
sudo apt-get install vorbis-tools
gst-register-0.8

For more detailled instructions visit the Ubuntu Wiki.

There is also an automated setup, which installs most restricted formats automatically. This is highly recommended. To run it, open a terminal session and enter:

wget http://download.ubuntuforums.org/ubuntusetup/ubuntusetup.sh
sudo sh ubuntusetup.sh

You will be asked several times to select "Yes" or "No". To continue, you must select Yes.

Is there an alternative?

Yes, you can install the VideoLanClient (VLC) by typing:
sudo apt-get install vlc

VLC has many integrated codecs, such as MP3, DivX, Xvid, Ogg Vorbis and MPEG. For a full list please have a look at the VLC homepage.