This is an introductory article for media players on Linux, in general, and openSUSE, in particular. After reading it, you will have a better understanding of the media playing subject and will also have installed a player or two with all codecs.
First, an explanation of the codec situation. Codecs are algorithms that represent the raw video and audio in a digital format. This representation has to take up as little space as possible while keeping as much detail of the original as possible. These two goals go pretty much against each other, so the aim of any codec is to fulfill them the best it can. This is why there are so many codecs, they are attempts from a lot of different people to come close to those goals. The math used in these algorithms is hardcore and the effort to implement them in a program is quite big. Therefore most of the codec makers want to get some money for it, and you can’t blame them. So they charge somebody, which can be the users viewing the media, the companies that make hardware or software media players, the companies distributing media and so on. They publish the terms in which they want to be paid in the codec license of use.
The reason why you don’t have all the codecs included in openSUSE out-of-the-box is because makers of most codecs would want you or openSUSE to pay for them. This is unworkable for SUSE, therefore you have to perform a few extra steps described here to get the codecs from somewhere else.
Fortunately, there are a few codecs that are free for the user and for SUSE, because they make money in other, indirect ways. These already work out-of-the-box, for example: Theora from Xiph.org, WebM from Google.
There are three major “engines” for video in Linux, all of them are quite good:
Also, I’d like to make a honorable mention of avifile, that was the first, a long time ago, when you had to compile it by yourself and the codecs too. It’s so much easier now…
Around these three major engines that do the actual playing, there is a quite large number of front-ends. Their function is presenting an user interface that is either skin-able or uses native controls from a particular desktop environment, like KDE or Gnome.
What you need to do is install an engine and a front-end, There are a few rare cases of files encoded with a weird codec that a certain engine might have difficulties with. To cover even such rare cases, I suggest installing two engines.
For openSUSE, there is a contributor site that makes packages for all these engines, codecs and front-ends. This is packman. It deserves enormous thanks for the service it delivers!
Step one is adding the packman repository
You open YaST2 and go to Software Repositories. Click [Add], choose Community Repositories, choose packman.
Step two is installing the engines and front-ends
A few words, tips & tricks about each one of them:
It’s a very capable player, it can output on a large variety of devices and supports video acceleration of Nvidia cards. About that: when you play video, the process of unpacking the data that is represented in the digital format will use quite a bit of processing power. This is usually from your computer processor. However, the video card is also capable of that, and it might do it faster than the CPU. This really becomes important to you only if your processor can’t do it fast enough and the movie plays slower than normal or maybe it keeps freezing for short periods. Having the video card take over the decoding can also be useful if you’re doing something else on the computer at the same time.
While all the video card makers have video acceleration in their hardware, only Nvidia has a driver that supports that under Linux (NVIDIA binary driver installation howto here). Unfortunately the driver is closed source. At least, it works quite well. The name of the API for Nvidia video acceleration is VDPAU.
Another nice feature of MPlayer is that it has multi-threading support for CPU. This means that it can use all the cores in a multi-core processor. Again, this really becomes important to you if one core cannot do it alone, or the video card cannot do it either, or you have a video card other than Nvidia.
To install, go to YaST2 Software Management and search for MPlayer. Then select at least these two packages:
- MPlayer – this is the actual engine, you can use it to play media from command line, ie. Konsole or Gnome Terminal
- gmplayer – this is the “official” skin-able front-end
You could also try some other front-ends in addition to gmplayer (you can even have several installed, at the same time):
- smplayer or umplayer – these are based on Qt, so they will look good in KDE. umplayer has a Windows version too, if you need a powerful player.
- gnome-mplayer – this will fit well into Gnome
After you select these, YaST will resolve required dependencies and prompt you to install a bunch of packages. They are various codecs, libraries and such. YaST is great.
How to enable and disable VDPAU
For VDPAU to work you have to install the Nvidia closed source (boo) driver. openSUSE has the nouveau open source driver, by default. This is being developed by a few volunteers with a great deal of effort. So far it’s good enough for desktop effects graphics acceleration, but it does not support VDPAU, yet.
If you have installed the Nvidia driver, MPlayer will try to use VDPAU by default. This is what you want if you play a file encoded with a codec like H.264 (.mkv or .mp4) which is supported by the hardware decoder on the video card. However, for codecs that aren’t supported, you will want to use the CPU.
Like any Linux program, MPlayer has global options that are set for all users defined on the machine and per-user options that can override the global options.
- global options are in /etc/mplayer. They can be changed by root, by editing the files
- per-user options are in /home/username/.mplayer. They can be changed by the user by editing the files or by making settings in the gmplayer GUI
Note that the command line mplayer uses /etc/mplayer/mplayer.conf, /home/username/.mplayer/config and the GUI gmplayer uses gui.conf.
The option dealing with the output driver is vo. To see what output drivers you have available, you can type this in Konsole or Gnome Terminal:
mplayer -vo help
This will give you a long list, but you will actually use two, at most: vdpau and xv.
- vdpau uses the video card hardware to accelerate decoding of supported codecs. These are H.264 (usually .mkv and .mp4) and VC-1 (some rare .wmv files). The problem with using vdpau all the time is that it doesn’t support other codecs than those
- xv uses the CPU for all codecs. If you have a fast CPU and don’t want any fuss, you could just use this. And if you don’t have Nvidia, it’s the only option. You will still want to enable multi-threading, see below
What you need to add in the options file:
In the command line this goes like this
mplayer -vo vdpau,xv mplayer -vo vdpau mplayer -vo xv
If you want to see a list of supported codecs, look at this:
mplayer -vc help
How to enable multi-threading
Enabling multi-threading is useful no matter if you use VDPAU or not. First, you have to find out how many processor cores you have.
cat /proc/cpuinfo | grep processor
Note that it starts with zero, so if the last line says 7, you actually have 8. On Intel processors with hyperthreading active, this would mean there are 4 actual, physical cores, but nevermind, you can say there are 8. Add this to option files (preferably /etc/mplayer/mplayer.conf). Replace N with you own number of cores.
lavdopts = threads=N
Other option you might like is to start playing in full screen by default:
fs = true
MPlayer automatically loads subtitle files that have the same name as the video. You can manually load subtitles with a different name using -sub filename-of-subtitle.ext. If the code page is not auto-detected, it can be forced with -subcp. Examples: -subcp utf8 or -subcp latin2. These are options for the command line, you can probably discover how to do it yourself in the front-ends.
This is a good alternative to MPlayer. It does not have yet VDPAU support in the stable version, but it’s being worked on. Also the “official” skin-able front-end is made with some ancient X11 library and I would advise against it. However, there’s a great KDE front-end called Kaffeine and there’s the official GTK front-end gxine (which I just tested and it didn’t work).
To install, go to YaST2 Software Management and search for Kaffeine. Select that, then search for libxine1. openSUSE comes with a set of xine libraries that have some codecs disabled for the reason explained in the beginning. They can be replaced with the packman libraries. Select these:
Go to “Versions” tab, in the lower half of the YaST Software Management window, and select the packman versions for all these packages.
This is a player that is famous in Windows, so if you happen to be familiar with it, you might prefer using it in Linux too. It has a command line version, a Qt front-end and a Gnome front-end.
To install, go to YaST2 Software Management and search for vlc. Select these:
- vlc-qt or vlc-gnome
Allow YaST to install some other packages that are needed (YaST is great).
Last step is installing a DVD decryption library
This is needed to be able to play encrypted DVDs. That is an old futile attempt of the movie industry to restrict what you can do…
- you open YaST2 and go to Software Repositories. Click [Add], choose Community Repositories, choose libdvdcss
- then open Software Management and search for libdvdcss2
That is it, you are now fully equipped to play any video on your Linux openSUSE installation.