openSUSE Tumbleweed 配置多媒体播放

从 Windows 转到 Linux 的时候,最不适应的可能就是多媒体播放了。在 Windows 上我们有 KMPlayer 或者 Potplayer 这样的全能播放器,配合 Free-Codecs 上的全能解码器包,几乎不会有任何难以对付的音视频了,而且还不需要多少配置。可是在 Linux 上的默认情况下我们几乎总是会遇到无法播放的音视频。

我最初开始接触 Linux 的时候为了找一款顺手的播放器和各种解码器真可以说是历经千辛万苦。现在的情况似乎要好很多,大名鼎鼎的 VLC 播放器几乎已经是无需多想的选择。而解码器尽管因为版权问题无法直接集成到 Linux 的系统安装中,也已经有人做集成的一键安装包了。

安装播放器和解码包

至少 openSUSE 上的一键安装包还是挺方便的。尽管这个安装包确实存在,但是 http://opensuse-community.org/ 这个页面却说因为技术原因暂不提供,而是让大家去参考 http://opensuse-guide.org/codecs.php 上的安装方法。

据说 VideoLan 安装源的 VLC 经常出一些莫名其妙的问题,不建议使用。另,据说 packman 源的最好了。

仔细看了一下这个一键安装包还有引用页上的安装说明,只要对照安装一些软件包就可以了。做了个汇总,如下。

# Extra Multimedia Codecs for openSUSE KDE
# Maintained by the following authors:
# * Martin Schlander <mschlander@opensuse.org>
# * Bruno Friedmann <bruno@ioda-net.ch>
# * Thomas Langkamp <langkamp@tomblog.de>
# repositories
# Packman
zypper ar -f -p 99 -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbleweed/ packman
# libdvdcss2 # 如果不需要播放 DVD 则不需要 libdvdcss2
zypper ar -f -p 100 -n libdvdcss http://opensuse-guide.org/repo/openSUSE_Tumbleweed/ libdvdcss 
zypper install libdvdcss2 
# 所有需要的都集中到一起安装吧 
zypper install k3b-codecs ffmpeg lame gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-plugins-ugly-orig-addon gstreamer-plugins-libav vlc vlc-codecs

解码包的安装到这里基本上就已经结束了。在 Tumbleweed 上还有点特别的地方在于,需要将已经安装的包都升级/切换来源到 packman 上面,避免交叉使用安装来源造成软件冲突,

$ sudo zypper dist-upgrade --repo packman

更新:修正一下上面的从 packman 升级的命令为,

$ sudo zypper dist-upgrade --from packman

下面是一些附加的说明。

最后安装的一堆包会带入一些附加的包,包括,

k3b-codecs:
libkcddb5 libmusicbrainz4

ffmpeg:
libavdevice56 libavfilter5 libavresample2 libpostproc53 libvdpau1

gstreamer-plugins-bad:
libfluidsynth1 libgstadaptivedemux-1_0-0 libgstbadbase-1_0-0 libgstbadvideo-1_0-0 libgstbasecamerabinsrc-1_0-0 libgstcodecparsers-1_0-0 libgstgl-1_0-0 libgstmpegts-1_0-0 libgsturidownloader-1_0-0 libgstwayland-1_0-0 liblash1 liblrdf2 libmms0 libSoundTouch0 Mesa-libGLESv2-2

gstreamer-plugins-ugly:
libsidplay1

# 2016.05.03,从上面的安装指令中去掉了这个,因为似乎不需要。
# 2017.04.23,重新加入
gstreamer-plugins-ugly-orig-addon:
libx264-148

至于这些包的作用,可以参考一键安装包中的说明,

libdvdcss2
Select this to be able to play Encrypted DVDs.
A simple library designed for accessing DVDs without having to bother about the decryption. Install this to be able to play Encrypted DVDs.
 
vlc-codecs(播放 H264 视频需要此包)
Codecs for VideoLan Client (VLC).
This Package enhances the functionality of the VLC VideoLAN Client with Codecs that are not available in a stock openSUSE distribution.
 
k3b-codecs
Extra Multimedia Codecs for K3b
This package extends the opensuse package with some codecs. K3b is a CD burning application that supports Ogg Vorbis, MP3 audio files, DVD burning, CDDB, and much more.
 
ffmpeg
Hyper fast MPEG1/MPEG4/H263/RV and AC3/MPEG audio encoder.
 
lame
LAME adds support for encoding audio data into the MP3 format
LAME is an educational tool to be used for learning about MP3 encoding. The goal of the LAME project is to use the open source model to improve the psycho acoustics, noise shaping and speed of MP3. Another goal of the LAME project is to use these improvements for the basis of a patent free audio compression codec for the GNU project.

gstreamer-plugins-libav
GStreamer libav plug-in
GStreamer libav plug-in contains one plugin with a set of elements using the libav library code. It contains most popular decoders as well as very fast colorspace conversion elements.
 
gstreamer-plugins-bad
GStreamer Bad Plug-ins
GStreamer Bad Plug-ins is a set of plug-ins that aren't up to par compared to the rest. They might be close to being good quality, but they're missing something - be it a good code review, some documentation, a set of tests, a real live maintainer, or some actual wide use.

gstreamer-plugins-ugly
GStreamer Ugly Plug-ins
GStreamer Ugly Plug-ins is a set of plug-ins that have good quality and correct functionality, but distributing them might pose problems. The license on either the plug-ins or the supporting libraries might not be how we'd like. The code might be widely known to present patent problems.

gstreamer-plugins-ugly-orig-addon
GStreamer Ugly Plug-ins
GStreamer Ugly Plug-ins is a set of plug-ins that have good quality and correct functionality, but distributing them might pose problems. The license on either the plug-ins or the supporting libraries might not be how we'd like. The code might be widely known to present patent problems.

gstreamer-plugins-good
GStreamer Streaming-Media Framework Plug-Ins
GStreamer is a streaming media framework based on graphs of filters that operate on media data. Applications using this library can do anything media-related, from real-time sound processing to playing videos. Its plug-in-based architecture means that new data types or processing capabilities can be added simply by installing new plug-ins.

lame
LAME adds support for encoding audio data into the MP3 format

也可能是因为我平常也就看看常见格式的视频吧,暂时还没有发现什么问题。

一个 H264 播放问题

有 packman 上 vlc-codecs 就可以播放 H264 视频了。如果没有安装这个,播放时会提示,

Codec not supported:
VLC could not decode the format "h264" (H264 - MPEG-4 AVC (part 10))
Codec not supported:
VLC could not decode the format "a52 " (A52 Audio (aka AC3))

并且查看 vlc 设置的话会发现 vlc – Tools – Preferences – Input / Codecs – Hardware-accelerated decoding 这里的设置为灰色不可配置。

但是即便安装了,播放时可能还有两个可能状况

  • 有些 H264 编码的视频在播放的时候卡顿,甚至卡死。
  • 然后还有一个视频在播放的时候直接显示个绿色(或黑色?)背景,能听到声音。

看到 ArchLinux 上一个方法,禁用硬件加速就好了。

  • Tools –> Preferences,然后在 “Input / Codecs” 那里将 Hardware-accelerated decoding,由 Automatic 改成 Disable(禁用)就好了。
  • (可选)Tools –> Preferences,在 “Video” 那里,将 Accelerated video output (Overlay) 取消选择。

保存设置后关闭 VLC 再打开就好了。

这一般是因为独立显卡的驱动问题。不再展开了,我都禁用 NVIDIA 独立显卡了。

新增问题:全屏时画面只显示在屏幕左上角

这几天突然发现用 VLC 播放视频的时候全屏显示不正确:VLC 界面确实是全屏的,有字幕的话也是显示在整个屏幕的下方中间位置,但是视频画面如果不是跟屏幕分辨率一样的话,就会只显示在屏幕左上角的位置 —— 似乎画面并没有按照实际显示器进行缩放和/或置于整个显示器的中心位置。

于此同时还观察到了视频播放卡顿及画面破碎的问题,以及系统的 swap 被很快填满的问题。

改了个 VLC 的设置就好了Tools(工具) –> Preferences(首选项),然后在 “Video“(视频)的 “Display”(显示)那里将 那里将 Output(输出)(位于 Windows Decorations 下面)由 Automatic 改成 OpenGL GLX Video Output XCB(OpenGL GLX 视频输出),然后关闭 VLC 再打开就好了。

这个 OpenGL GLX 也许是与 System Settings(系统设置)–> Display and Monitor(显示与监视器)–> Compositor(合成器)里的 Rendering backendOpenGL interface 相关的。我设置的分别是 OpenGL 3.1GLX

当然也许也跟显卡有关。我的是 ThinkPad T420s 带的 NVIDIA NVS 4200m 显卡和 Intel CPU i5-2520m 集成的显卡。因为独立显卡很少用到,又不好配置,就给禁用了。

又一个问题:画面黑色,有声音

再次碰到一个 VLC 播放视频只有声音没有图像的问题。

联想起昨天上午例行升级了,也许是升级过程出了差错。检查了一下 vlc 相关的包才发现 vlc 的版本跟相配套的解码器等版本不一致。是因为忘记什么时候出于测试目的将且仅将 vlc 包改到了 openSUSE-Tumbleweed-oss 源了,而其他的还是用的 packman 的源。恰好这次升级的时候 packman 的源比主源里的 vlc 高了一个小版本。重新搞了一下就好了。

2016.05.30 更新

经确认,该问题不是由由于混淆了 oss 和 packman 的源的问题。现在有时候 openSUSE Tumbleweed 里的 vlc 及组件会比 packman 里的版本稍高一点。但是并没有导致该问题。

问题的原因在于系统里该用户的 vlc 配置文件出了问题,至于具体是什么问题就不知道了。删除了 ~/.config/vlc 后重新打开并配置 vlc 就没有问题了。

2017.04.23

更新安装源和安装指令。

这是水景一页迁移到 openSUSE 系统之后的一系列配置记录之一。

2018.06.18

根据更新的情况调整需要安装的软件包。©

本文发表于水景一页。永久链接:<http://cnzhx.net/blog/opensuse-tw-multimedia/>。转载请保留此信息及相应链接。

8 条关于 “openSUSE Tumbleweed 配置多媒体播放” 的评论

  1. 引用通告: openSUSE Tumbleweed 初始配置记录 | 水景一页

    • 估计是因为多媒体方面的专利太多而开源解决方案不够好——甚至可能是不能去解决——所以只能把这些事情留给用户自己去折腾。不过现在已经比以前容易多了,或者说不比在 Windows 里安装 free-codecs 解码麻烦。

  2. 由于NVIDIA的升级搞坏了显卡驱动配置,导致VLC不能正常播放了,多谢你给出的解决方法,解决了我的问题。文章有个小瑕疵,packman 源写成 pacman 了。

    • 我也是因为 NVIDIA 显卡折腾了好几回,后来干脆禁用了。以后都不打算买带 NVIDIA 显卡的机器了。
      谢谢提醒,等会儿用上电脑了再给改改。

  3. 引用通告: openSUSE Tumbleweed 升级 Linux 内核到 4.10.8 | 水景一页

时间过去太久,评论已关闭。
如果您有话要说,请到讨论区留言并给出此文章链接。
谢谢您的理解 :-)