Install Multimedia Codecs on Linux [2023]

Installing Multimedia Codecs On Linux

If you have trouble playing any media such as a Video or an audio file on your Linux PC, chances are that you are missing important media codecs which are required to play that particular audio or video file. Most Linux distributions nowadays offer to install multimedia codecs right during the installation procedure, and some of them even do that in the post-install welcome screen.

Even then, most Corporate managed Linux distributions (such as Fedora) have stopped shipping the patented media codecs in their Linux install to avoid possible lawsuits by the patent holders. The patented codecs can still be installed, but through third-party repositories. If the codecs are not installed, then either the media will play using software decoding (which uses more battery if you’re on a laptop) or not play at all.

In this tutorial, we will try to install all the essential media codecs that you will need to just plug-and-play every kind of media file possible on your Linux distribution.

Installing Codecs on Ubuntu and Its Variants

Installing multimedia codecs on various Linux distributions is essential for smooth media playback. On Ubuntu and its variants, use the ubuntu-restricted-extras package. For Fedora, enable the RPMfusion repository and install the necessary packages. On OpenSUSE, use the Packman third-party repository. Popular media players like VLC and MPV can also pull necessary packages during installation, simplifying the process.

Let’s start with the following commands.

sudo add-apt-repository multiverse
sudo apt update
sudo apt install ubuntu-restricted-extras

On Kubuntu, instead of apt install ubuntu-restricted-extras, run:

sudo apt install kubuntu-restricted-extras

Similarly, on Xubuntu, you can use the following command:

sudo apt install xubuntu-restricted-extras

If you’re using Lubuntu, then you can try installing codecs with this command:

sudo apt install lubuntu-restricted-extras

You will be greeted with the EULA in the Terminal screen, just hit Tab and accept the license agreements.

Installing Codecs on Ubuntu-Based Distributions

If you are using Linux Mint, then it is recommended that you should install the meta-codecs package. Just open a Terminal and type the following commands:

sudo apt install -y mint-meta-codecs

All the essential packages will be installed without any prompt.

On Pop_OS, Peppermint OS and other Ubuntu based distro, ubuntu-restricted-extras will be the right package to install.

sudo apt install -y ubuntu-restricted-extras

Installing Codecs on Fedora Workstation

On Fedora workstation, you can type the following command to first enable the RPMfusion repository by typing this command in your Terminal window:

# Free
sudo dnf install \
  https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
# Non Free
sudo dnf install \
  https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Installing RPMfusion On Nobara Linux
Installing RPMfusion On Nobara Linux

Once you have enabled both the RPMFusion repositories, type the following command to install all the important codecs:

sudo dnf update 
sudo dnf install gstreamer1-plugins-{bad-\*,good-\*,base} gstreamer1-plugin-openh264 gstreamer1-libav --exclude=gstreamer1-plugins-bad-free-devel

sudo dnf install lame\* --exclude=lame-devel

sudo dnf group upgrade --with-optional Multimedia
Installing Multimedia Codecs On Nobara Linux
Installing Multimedia Codecs on Nobara Linux (Fedora-Based)

On Nobara Linux (Fedora based), most of the multimedia codecs are installed out of the box.

Installing Codecs on OpenSUSE

On OpenSUSE, you can install all the required packages from the Packman third party repository. To add it as a source to your Zypper package manager, just type the following command in your Terminal:

sudo zypper addrepo -cfp 90 'https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_$releasever/' packman

Now, install all the codecs with this command:

zypper install --allow-vendor-change ffmpeg-4 lame gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-plugins-ugly-orig-addon gstreamer-plugins-libav libavdevice57 libdvdcss2 vlc-codecs

Make sure all your multimedia packages are coming from the Packman Repository:

zypper dist-upgrade --from packman

Conclusion: Enjoy Your Media on Linux

We do recommend installing a widely supported media player on your PC such as the VLC media player or MPV because they pull all the necessary packages with them when you install them, and you do not have to install the codecs manually. I hope you were able to install the codecs and successfully run the required media file on your distribution. If you have any doubts regarding any of the steps involved, do let me know in the comments section.

References