You've switched to Linux, and now you're ready to start listening to music and watching video. But -- oh no -- the file won't play!

LinuxCodecs-Video-Error

This is a moment that surprises many new Linux users. Your Windows and Mac OS X computers played media files out of the box. So do your phones and tablets. Why, then, doesn't Linux?

Simply, your distribution didn't come with the necessary codecs. This wasn't an oversight. There are legal and ethical reasons why some projects don't pre-install codecs. I'll try to keep this simple, and then we'll dive into what you can do about it.

What are Codecs?

A codec is what tells your computer how to decode or encode a data stream. This is relevant whenever you want to watch video, whether locally or on the web. We could spend all day listing various video codecs and how they work. Fortunately, that is something we've already covered.

Codecs are also necessary when you're playing audio. The most common music format is MP3 (you may recall how portable media players were often called MP3 players, despite their ability to play other formats). Alternatives include AAC, WAV, and Ogg. Audio isn't as complicated as video, but something still needs to tell your favorite music application how to play these files.

Without the necessary codecs, you can't play particularly formats, nor can you create them.

LinuxCodecs-Music-Error

That means that while you can easily record an audio file for a podcast using Linux, you can't save it in some of the more popular formats until you get your hands on the right software. You probably won't be able to listen to or watch downloads of your favorite feeds either.

This sounds like essential functionality, especially today. So, why don't all Linux distributions ship with codecs?

Multimedia and the Law

Many common multimedia formats are patented. This usually doesn't affect users directly, as they're welcome to stream whatever they want on the devices they own. But patent holders charge money from the companies that make those products.

Microsoft, Apple, Google, and computer OEMs pay royalties to sell computers that play encumbered multimedia formats. This can be expensive, which is why Microsoft stopped offering DVD playback on Windows 8 back in 2012. The company felt that paying a royalty for each computer running Windows 8 didn't make sense. Many of them, if not most, would lack disc drives.

Linux distributors aren't selling a product. They're giving away software for free and not paying a license for every download.  These projects are only able to ship free, non-restricted formats. Examples of these include Ogg, Matroska, and WebM.

Installing proprietary codecs isn't difficult, but it may not be legal in your country. Linux has a global reach, so some distributions make restricted codecs easy for anyone to install. The downside of this approach is a person can run afoul of the law without even knowing. An Ubuntu user in the US technically shouldn't have access to free versions of these codecs, but the distribution does not make this clear. That said, it's unlikely this ambiguity will land you in any real trouble.

How to Install Codecs

Some distributions ship with codecs pre-installed. Most of the major ones don't. How you install codecs varies depending on which one you're running. Though in most cases, you have the option to buy a codec pack.

Here is what you can expect from several of the more common distributions.

Ubuntu

Ubuntu doesn't provide codecs out of the box, but it does allow users to download the MP3 codec from Fluendo during installation. This is a codec that Fluendo has made available for anyone to install for free legally, as the patent holders don't charge end users.

Others are available through the Ubuntu Software Center as restricted extras.

LinuxCodecs-Ubuntu-Software-Center

Fedora

Fedora doesn't provide access to any proprietary codecs, either pre-installed or in repositories. This is partly due to a principled dedication to only sharing free software. This is also due to the project being sponsored by Red Hat, an American company subject to US law.

You can gain non-free codecs by adding the unofficial RPM Fusion repository.

OpenSUSE

Like the others, a fresh openSUSE install will leave you with free codecs only. The project has made an extensive list of formats considered restricted.

OpenSUSE encourages you to buy codecs, but the community suggests an alternative approach that doesn't cost money.

Arch Linux

As a build-your-own distribution, Arch Linux doesn't come with codecs. It comes with nothing. But the project includes restricted formats in its repositories. You can get the codecs when you install the libraries needed to play them.

How to Avoid the Issue Entirely

If you don't want to install codecs, you can install a distribution that includes them out of the box. Linux Mint is one aimed at new users that play proprietary codecs out of the box. Adobe Flash, MP3, and even the capability to play DVDs come included (something else you're recommended to buy). Those who want to use Linux Mint but don't want to risk legal issues can download a No Codecs version.

Technically, you're not entirely out of the woods. Just as with Windows and Mac OS X, you may still encounter the occasional media format that your machine doesn't yet understand. The list of codecs already in existence is surprisingly huge.

LinuxCodecs-Codecs

Though, chances are, if you throw VLC at a video, you will probably get it to work. MPlayer is another media player that can play pretty much anything.

Easy Listening, and Keep Watching

Linux may not make codecs immediately available, but once they're installed, you're good to go. Many programs use the same libraries in the backend, such as GStreamer or Xine. You should be able to fire up various music and video players without having to configure each. And in this area, you'll find many to choose from.

So despite the initial setup, you can still use a Linux computer to manage your music libary, edit home videos, and watch some of your favorite movies. Don't let those initial errors dampen your expectations. You may find your experience better than the one you left behind (again, there are so many free music players for you to try).

Are you struggling to get certain audio or video files to play under Linux? Have you had a difficult time getting codecs to work on your distribution? Ask for help or share your experience in the comments below!

Image Credit: Angry Penguin by Wnong via Shutterstock, Audio and Video File Format Icons. 15 common digital audio and video file formats isolated on white.