===========================
Howto: MPlayer with CoreAVC
===========================
This guide will work on Ubuntu 8.10 "Intrepid Ibex", 9.04 "Jaunty Jackalope" and 9.10 "Karmic Koala", both 32 and 64bit.
Although it has not been tested on previous Ubuntu releases, there is a good chance it will work with them too.
It should also work with very minimal changes in any other modern GNU/Linux distribution.
The version of CoreAVC that has been tested is 1.9.5.
When you ask for help about your video not playing, plase include the FULL output from MPlayer in your post!
What this guide is
This guide will explain in detail the steps needed to install and configure a build of the MPlayer video player that will be suitable for use with the CoreAVC H.264 decoder, using code from the coreavc-for-linux project. The text of this document is licensed under the Simplified BSD License as used by the FreeBSD project (the license statement for this document can be found at the bottom thereof).
What this guide is not
This guide is not a comprehensive MPlayer build guide (another guide on this subject exists on these forums). It strives to be quick, simple, no-nonsense and to-the-point, and therefore will describe only the steps required to get what its title says: a build of MPlayer with CoreAVC support.
Of course, if you need to compile MPlayer with specific options, or if you desire to stick with The Ubuntu Way™ and create a .deb package for your build, you are perfectly free to do so, but it is not the point of this guide to tell you how do to that and I refer you to the aforementioned one, which can very well be used in conjunction with this one.
What is CoreAVC and why would I want to use it?
CoreAVC is a proprietary MPEG-4 AVC (Advanced Video Coding, aka H.264) decoder. H.264 uses extremely advanced compression algorithms to achieve much better video compression than its predecessors, but with the drawback that much more processing power is needed in order to properly decode the resulting video streams.
The MPlayer video player ships with the Free libavcodec library, which provides it with H.264 decoding capabilities. However, many people experience video stuttering, frame-dropping, or even impossibility to playback H.264 streams at all with it, especially with high-definition material on older hardware. CoreAVC offers much better decoding performance than libavcodec, and therefore might be a solution for those people.
You will of course need a valid CoreAVC license key in order to be able to use it with MPlayer (there is a trial version of CoreAVC, but I could not test it myself, feel free to do it and report your results!), and I shall remind you that as per the forums rules, anyone's asking or offering CoreAVC itself and/or a CoreAVC license key will result in action being taken by the forum staff.
Get the sources
First, let's create a directory to work in, install the necessary build tools, and download the MPlayer sources as well as the coreavc-for-linux code. Karmic users will also need to install gcc 4.3, as the default gcc in Karmic (4.4) causes problems with MPlayer:
Code:
mkdir ~/mplayer-with-coreavc
cd ~/mplayer-with-coreavc
sudo apt-get install build-essential subversion pkg-config xorg-dev
sudo apt-get install gcc-4.3 # Karmic users
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
svn checkout http://coreavc-for-linux.googlecode.com/svn/trunk/ coreavc-for-linux
The next step is to install DShowServer, which is the program that will allow MPlayer to make use of CoreAVC. It is different depending on your architecture (i.e. whether you use the 32bit or 64bit version of Ubuntu).
Patch, build and install DShowServer (i386/32bit users)
First, we need to patch the sources to make them compatible with recent versions of MPlayer:
Code:
cd coreavc-for-linux
wget -qO - "http://pastebin.com/pastebin.php?dl=f7ca459d" | patch -p0
Then we build the dshowserver and registercodec binaries and copy them into /usr/local/bin.
Code:
cd dshowserver
make
sudo cp dshowserver registercodec /usr/local/bin
Build DShowServer statically on a 32bit system (amd64/64bit users)
DShowServer will not compile on a 64bit system (you can try!). That means you will have to compile it statically on a 32bit system, and copy the resulting binaries onto your 64bit system. To do this, download the coreavc-for-linux sources on your 32bit system as described above (you don't need the MPlayer sources), and compile the DShowServer binaries with the STATIC flag:
Alternatively, I have a tarball containing those binaries (compiled on Karmic with coreavc-for-linux r82 and the above patch) that you can use.
Install and register CoreAVC
Copy the CoreAVCDecoder.ax file (located in the CoreAVC directory under Windows's "Program Files") in /usr/local/lib/win32/ (create that directory if it does not exist). You can either copy this file from your existing Windows installation of CoreAVC or, if you don't have one, run the Windows installer in WINE and copy it from your WINE virtual drive.
The next step is to enter your CoreAVC license key in the registry (don't forget to replace the bogus one in the command with your real one!):
Code:
test -d ~/.mplayer || mkdir ~/.mplayer
registercodec -r ~/.mplayer/registry32 -k "HKLM\\Software\\CoreCodec\\CoreAVC Pro\\Serial" -v "55555-55555-CORE-55555-5555"
Then, to check that it's working:
dshowserver will currently crash during this step. This is caused by a patch that fixes a playback problem, you can probably just ignore this step for now.
Code:
dshowserver -c CoreAVCDecoder.ax -s 1280x720 -g 09571a4b-f1fe-4c60-9760de6d310c7c31 -b 12 -f 0x34363248 -o 0x30323449
If all went well, that command should return:
Code:
3248 -o 0x30323449
No id specified, assuming test mode
Opening device
len: 992
ProductVersion: 1.8.5
Decoder supports the following YUV formats: YUY2 UYVY YV12 I420
Decoder is capable of YUV output (flags 0x2b)
Setting fmt
Starting
Initialization is complete
Note for CoreAVC 1.9 users: CoreAVC 1.9 supports GPU decoding on nvidia graphics card using nvidia's CUVID interface. Therefore, you will see the following warning message when running the above command:
Code:
Win32 LoadLibrary failed to load: nvcuvid.dll, /usr/lib/win32/nvcuvid.dll, /usr/local/lib/win32/nvcuvid.dll
You can safely disregard it. The absence of the nvcuvid.dll library will not affect the normal operation of CoreAVC.
Patch, build and install MPlayer
Now let's move to the MPlayer source directory and configure it:
Code:
cd ~/mplayer-with-coreavc/mplayer
./configure
Karmic users will need to configure MPlayer to use gcc 4.3 for compilation:
Code:
CC=gcc-4.3 ./configure
There are of course a lot of options to choose from here, but once again, it's outside the scope of this guide. If the configuration has completed successfully and the options look good to you, you can apply the coreavc-for-linux patch:
Code:
wget "http://pastebin.com/pastebin.php?dl=f1c7c15f7" -qO - | patch -p0
As of MPlayer r29367, the output looks like this:
Code:
(Stripping trailing CRs from patch.)
patching file libmpcodecs/vd.c
Hunk #1 succeeded at 25 (offset -4 lines).
Hunk #2 succeeded at 57 (offset -5 lines).
(Stripping trailing CRs from patch.)
patching file Makefile
Hunk #2 succeeded at 519 (offset 295 lines).
(Stripping trailing CRs from patch.)
patching file libmpcodecs/vd_dshowserver.c
Then we build and install MPlayer:
Code:
make
sudo make install
If the build fails, it is most likely because a change in the MPlayer source code broke compatibility with coreavc-for-linux or caused some other bug. Please report in the thread and I'll update the patch accordingly.
The last step is to copy the codecs.conf file from the MPlayer source directory in your ~/.mplayer directory if you don't have one already:
Code:
test -f ~/.mplayer/codecs.conf || cp etc/codecs.conf ~/.mplayer
Finally, open your codecs.conf file in your favourite text editor, and add this text at the bottom of it:
Code:
videocodec coreserve
info "CoreAVC DShow H264 decoder 1.3 for x86 - http://corecodec.org/"
status working
format 0x10000005
fourcc H264,h264 H264
fourcc X264,x264
fourcc avc1,AVC1 AVC1
fourcc davc,DAVC
fourcc VSSH
driver dshowserver
dll "CoreAVCDecoder.ax"
guid 0x09571a4b, 0xf1fe, 0x4c60, 0x97, 0x60, 0xde, 0x6d, 0x31, 0x0c, 0x7c, 0x31
out YV12,IYUV,I420,YUY2
Enjoy!
To check that CoreAVC is actually working, start MPlayer like this from your terminal:
Code:
mplayer -vc coreserve foo.mkv
The -vc coreserve argument will force MPlayer to use CoreAVC (of course, make sure you're trying to play a file containing a H.264 video stream, otherwise CoreAVC won't be able to decode it, and you will not see any video).
Of course, it would be a pain to add -vc coreserve to your command line every time you want to play a video. The best way to avoid that is to open your main MPlayer config file (located at ~/.mplayer/config) in your favourite text editor and add this line to it:
Do not forget the trailing comma, it is very important. Now, every time you will try to play a video, MPlayer will first try to decode it with CoreAVC and, if that fails, fall back to the normal codecs.
FAQs
I have the Ubuntu package for MPlayer installed. What do I do?
Since you are building a new version of MPlayer, you probably won't need the old one anyway, and it's recommended to uninstall it in order to avoid conflicts.
That being said, it is not an absolute requirement, and you can also use the build you've done with this guide alongside your "official" version. Simply omit the sudo make install step and run the mplayer binary directly from your build directory (you can also move and/or rename it to your convenience).
What if I want to uninstall my build?
Simply return to your source directory and do:
Code:
sudo make uninstall
If you have deleted your source directory, here is a list of the files most commonly installed, you can safely remove them.
Code:
/usr/local/etc/mplayer
/usr/local/bin/mencoder
/usr/local/bin/mplayer
/usr/local/bin/gmplayer
/usr/local/share/mplayer/skins
/usr/local/share/pixmaps/mplayer.xpm
/usr/local/share/applications/mplayer.desktop
/usr/local/share/man/man1/mplayer.1
/usr/local/share/man/man1/mencoder.1
How do I upgrade to a newer version of CoreAVC?
Simply copy the new version of the CoreAVCDecoder.ax file over your old one in /usr/local/lib/win32.
Legal stuff
Copyright 2009 Firas Kraïem. All rights reserved.
Redistribution and use in source and compiled forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in compiled form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS DOCUMENT IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS DOCUMENT, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Bookmarks