一条命令在 Ubuntu 中安装所有基本的媒体编解码器
媒体编解码器
如果你刚刚安装了 Ubuntu 或其他 [Ubuntu 特色版本](https://itsfoss.com/which-ubuntu-install/) 如 Kubuntu、Lubuntu 等，你会注意到系统无法播放某些音频或视频文件。


对于视频文件，你可以[在 Ubuntu 上安装 VLC](https://itsfoss.com/install-latest-vlc/)。[VLC](https://www.videolan.org/index.html) 是 [Linux 上的最佳视频播放器](https://itsfoss.com/video-players-linux/)之一，它几乎可以播放任何视频文件格式。但你仍然会遇到无法播放音频和 flash 的麻烦。


好消息是 [Ubuntu](https://ubuntu.com/) 提供了一个软件包来安装所有基本的媒体编解码器：ubuntu-restricted-extras。


![](/data/attachment/album/202002/19/111456h4optu6psocmuoo2.png)


### 什么是 Ubuntu Restricted Extras？


ubuntu-restricted-extras 是一个包含各种基本软件，如 Flash 插件、[unrar](https://itsfoss.com/use-rar-ubuntu-linux/)、[gstreamer](https://gstreamer.freedesktop.org/)、mp4、[Ubuntu 中的 Chromium 浏览器](https://itsfoss.com/install-chromium-ubuntu/)的编解码器等的软件包。


由于这些软件不是开源软件，并且其中一些涉及软件专利，因此 Ubuntu 默认情况下不会安装它们。你必须使用 multiverse 仓库，它是 Ubuntu 专门为用户提供非开源软件而创建的仓库。


请阅读本文以[了解有关各种 Ubuntu 仓库的更多信息](https://itsfoss.com/ubuntu-repositories/)。


### 如何安装 Ubuntu Restricted Extras？


令我惊讶的是，我发现软件中心未列出 Ubuntu Restricted Extras。不管怎样，你都可以使用命令行安装该软件包，这非常简单。


在菜单中搜索或使用[终端键盘快捷键 Ctrl+Alt+T](https://itsfoss.com/ubuntu-shortcuts/) 打开终端。


由于 ubuntu-restrcited-extras 软件包在 multiverse 仓库中，因此你应验证系统上已启用 multiverse 仓库：



```
sudo add-apt-repository multiverse
```

然后你可以使用以下命令安装：



```
sudo apt install ubuntu-restricted-extras
```

输入回车后，你会被要求输入密码，**当你输入密码时，屏幕不会有显示**。这是正常的。输入你的密码并回车。


它将显示大量要安装的包。按回车确认选择。


你会看到 [EULA](https://en.wikipedia.org/wiki/End-user_license_agreement)（最终用户许可协议），如下所示：


![Press Tab key to select OK and press Enter key](/data/attachment/album/202002/19/111459lzmfc7kzmtyimkgt.jpg)


浏览此页面可能会很麻烦，但是请放心。只需按 Tab 键，它将高亮选项。当高亮在正确的选项上，按下回车确认你的选择。


![Press Tab key to highlight Yes and press Enter key](/data/attachment/album/202002/19/111517pnw5wp1cil399l9p.jpg)


安装完成后，由于新安装的媒体编解码器，你应该可以播放 MP3 和其他媒体格式了。


#### 在 Kubuntu、Lubuntu、Xubuntu 上安装受限制的额外软件包


请记住，Kubuntu、Lubuntu 和 Xubuntu 都有此软件包，并有各自不同的名称。它们本应使用相同的名字，但不幸的是并不是。


在 Kubuntu 上，使用以下命令：



```
sudo apt install kubuntu-restricted-extras
```

在 Lubuntu 上，使用：



```
sudo apt install lubuntu-restricted-extras
```

在 Xubuntu 上，你应该使用：



```
sudo apt install xubuntu-restricted-extras
```

我一直建议将 ubuntu-restricted-extras 作为[安装 Ubuntu 后要做的基本事情](https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/)之一。只需一个命令即可在 Ubuntu 中安装多个编解码器。


希望你喜欢 Ubuntu 初学者系列中这一技巧。以后，我将分享更多此类技巧。




---


via: <https://itsfoss.com/install-media-codecs-ubuntu/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

If you have just installed Ubuntu or some other [Ubuntu flavors](https://itsfoss.com/which-ubuntu-install/) like Kubuntu, Lubuntu etc, you’ll notice that your system doesn’t play some audio or video file.

For video files, you can [install VLC on Ubuntu](https://itsfoss.com/install-latest-vlc/). [VLC](https://www.videolan.org/index.html) one of the [best video players for Linux](https://itsfoss.com/video-players-linux/) and can play almost any video file format. But you’ll still have troubles with audio media files and flash player.

The good thing is that [Ubuntu](https://ubuntu.com/) provides a single package to install all the essential media codecs: ubuntu-restricted-extras.

![Media Codecs In Ubuntu](https://itsfoss.com/content/images/wordpress/2020/02/Media_Codecs_in_Ubuntu.png)

## What is Ubuntu Restricted Extras?

The ubuntu-restricted-extras is a software package that consists various essential software like flash plugin, [unrar](https://itsfoss.com/use-rar-ubuntu-linux/), [gstreamer](https://gstreamer.freedesktop.org/), mp4, codecs for [Chromium browser in Ubuntu](https://itsfoss.com/install-chromium-ubuntu/) etc.

Since these software are not open source and some of them involve software patents, Ubuntu doesn’t install them by default. You’ll have to use multiverse repository, the software repository specifically created by Ubuntu to provide non-open source software to its users.

Please read this article to [learn more about various Ubuntu repositories](https://itsfoss.com/ubuntu-repositories/).

[What are Ubuntu Repositories? How to enable or disable them?This detailed article tells you about various repositories like universe, multiverse in Ubuntu and how to enable or disable them. So, you are trying to follow a tutorial from the web and installing a software using apt-get command and it throws you an error: E: Unable to locate package xyz](https://itsfoss.com/ubuntu-repositories/)![](https://itsfoss.com/content/images/wordpress/2019/03/ubuntu-repositories.png)


![](https://itsfoss.com/content/images/wordpress/2019/03/ubuntu-repositories.png)

## How to install Ubuntu Restricted Extras?

I find it surprising that the software center doesn’t list Ubuntu Restricted Extras. In any case, you can install the package using command line and it’s very simple.

[Open a terminal in Ubuntu](https://itsfoss.com/open-terminal-ubuntu/) by searching for it in the menu or using the [terminal keyboard shortcut Ctrl+Alt+T](https://itsfoss.com/ubuntu-shortcuts/).

Since ubuntu-restrcited-extras package is available in the multiverse repository, you should verify that the multiverse repository is enabled on your system:

`sudo add-apt-repository multiverse`


You may want to update the package cache if you are not running Ubuntu (Ubuntu does it automatically):

`sudo apt update`


And then you can install it in Ubuntu default edition using this command:

`sudo apt install ubuntu-restricted-extras`


When you enter the command, you’ll be asked to enter your password. When **you type the password, nothing is displayed on the screen**. That’s normal. Type your password and press enter.

It will show a huge list of packages to be installed. Press enter to confirm your selection when it asks.

You’ll also encounter an [EULA](https://en.wikipedia.org/wiki/End-user_license_agreement) (End User License Agreement) screen like this:

![Installing Ubuntu Restricted Extras](https://itsfoss.com/content/images/wordpress/2020/02/installing_ubuntu_restricted_extras.jpg)

It could be overwhelming to navigate this screen but don’t worry. Just press tab and it will highlight the options. When the correct options are highlighted, press enter to confirm your selection.

![Installing Ubuntu Restricted Extras](https://itsfoss.com/content/images/wordpress/2020/02/installing_ubuntu_restricted_extras_1.jpg)

Once the process finishes, you should be able to play MP3 and other media formats thanks to newly installed media codecs.

## Installing restricted extra package on Kubuntu, Lubuntu, Xubuntu

Do keep in mind that Kubuntu, Lubuntu and Xubuntu has this package available with their own respective names. They should have just used the same name but they don’t unfortunately.

On Kubuntu, use this command:

`sudo apt install kubuntu-restricted-extras`


On Lubuntu, use:

`sudo apt install lubuntu-restricted-extras`


On Xubuntu, you should use:

`sudo apt install xubuntu-restricted-extras`


I always recommend getting ubuntu-restricted-extras as one of the [essential things to do after installing Ubuntu](https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/). It’s good to have a single command to install multiple codecs in Ubuntu.

I hope you like this quick tip in the Ubuntu beginner series. I’ll share more such tips in the future.