I’ve got an old Pentium D 920. Over two years old, with the right ffmpeg options for mplayer and frame dropping enabled, this CPU can still play H.264 720p video at amazing quality in Linux. However, all 1080p and 1080i60 (camcorder M2TS files) choke horribly. The video drags, audio skips and the video is totally unwatchable. In my search for a better video codec, I came across CoreAVC, a closed source commercial codec for Windows, as well as the coreavc-for-linux project: an attempt to use those closed source drivers with various media players in Linux.

Unfortunately, the installation documents for coreavc-for-linux were months old, out-of-date and had few corrections for new bugs. The following are some of the common errors I found as well as the solutions I’ve found to get the trail version of the CoreAVC codec working on my Gentoo Linux system.

Installation

To start the installation, I created a new working directory within my home directory and checked out both the latest versions of mplayer and coreavc-for-linux (revision 82 for coreavc-for-linux and revision 28381 for mplayer). I then ran the configuration script for mplayer, applied the direct show patch from the coravc-for-linux project and proceeded to build mplayer:

mkdir coreavc
cd coreavc
svn checkout http://coreavc-for-linux.googlecode.com/svn/trunk/ coreavc-for-linux
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer
./configure
patch -p0 < ../coreavc-for-linux/mplayer/dshowserver.patch
make

At this point the new version of mplayer is ready. Rather than use the make install command, I wanted to keep this version of mplayer totally separate. So I copied the two executables I wanted directly to /usr/local/bin with new names like so:

su
cp mplayer /usr/local/bin/mplayer-coreavc
cp mencoder /usr/local/bin/mencoder-coreavc

At this point we have mplayer installed, but not the codec itself or the directshow server. We’ll start with the codec first. You can signup for a free trial on the official CoreAVC website. I would suggest the trial version first to make sure the codec works on your system. The download contains an executable installer, so you can either install it onto a windows system or install it using wine. After the install, copy the installed codec to the /usr/lib/win32 directory. The following example assumes you used wine. Your directory names may be different.

cd ~
su
cp ~/.wine/drive_c/Program\ Files/CoreCodec/CoreAVC\ 14\ Day\ Trial\ Edition/CoreAVCDecoder.ax /usr/lib/win32/

Before we go further we’ll install the directshow server. The wiki has instructions for compiling the server or using a precompiled binary. If you’re like me, you’re running a 64-bit system and can therefor not compile the binary from source. Doing so will give you a pretty massive compile error with several warning: ‘stdcall‘ attribute ignored messages from interfaces.h.

If you have a 32-bit linux system available, either real or a VM, or if you have somehow mastered the magic of cross compiling (I gave up on this years ago when I tried building a cross compiler for PPC), you can probably make this binary yourself. If you used the latest precompiled binary in the downloads section (r63 for Gentoo at the time of this writing) along with the 1.8.5 release of CoreAVC, you will get the following fault when trying to run it:

/usr/local/bin/dshowserver -c CoreAVCDecoder.ax -s 1280x720 -g 09571a4b-f1fe-4c60-9760de6d310c7c31 -b 12 -f 0x34363248 -o 0x30323449
No id specified, assuming test mode
Opening device
len: 992
ProductVersion: 1.8.5
Called unk_LoadImageA
Segmentation fault

This is due to a know issue with the 1.8.5 release of CoreAVC adding a dialog box in the initialization which is documented in Issue #62 and in a posting on Acmelabs’ Blog. In a later post, Acmelab gives his readers a precompiled version of release 77 which I’ve made a copy of for download: dshowserver-ia32-r77-acme.tar.bz2

Untar this file and copy the dshowserver/dshowserver and loader/registercodec binaries to your /usr/local/bin.

Now that you have the directshow server installed, you’ll need to add the trial serial number into mplayer’s virtual windows registry. The following command is known to work with version 1.7.0 and 1.8.5 of CoreAVC. Additional registry options can be found on the wiki

export REGISTRY=$HOME/.mplayer/registry32
registercodec -r $REGISTRY -k 
"HKLM\\Software\\CoreCodec\\CoreAVC Trial\\Serial" -v "55555-55555-CORE-55555-55555"

If you’re using the full version, you’d replace the word Trial with Pro. At this point you should be able to run the following command to test the codec:

/usr/local/bin/dshowserver -c CoreAVCDecoder.ax -s 1280x720 -g 09571a4b-f1fe-4c60-9760de6d310c7c31 -b 12 -f 0x34363248 -o 0x30323449

You should get the following response:

No id specified, assuming test mode
Opening device
Called unk_IsDebuggerPresent
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

You may get a serial number issue here. If you do, go back and check your registry key. Now the only thing left is the ~/.mplayer/codec.conf

Using the 28381 build of mplayer, I constantly got the following error using the default instructions for the codec.conf:

==========================================================================
Forced video codec: coreserve
Cannot find codec matching selected -vo and video format 0x3267706D.
Read DOCS/HTML/en/codecs.html!
==========================================================================

Also, using the default instructions on a current built of mplayer can also lead to seeing this error in the mplayer output:

This codecs.conf is too old and incompatible with this MPlayer release!

This is because newer version of the codecs.conf must have a release line at the top of the file to prevent conflicts with other codec configurations as stated in issue #61

After playing with my configuration file a lot and with no results, I eventually found a configuration file in comment 28 on issue 14 that worked. I’ve made the configuration file available here as well: codecs.conf

Playback

When running mplayer-coreavc, you made need the following options to force mplayer to use coreavc and also to have smooth playback. Obviously, replace the example file I have with an HD movie you have on your file system.

/usr/local/bin/mplayer-coreavc -vc coreserver -framedrop -nocorrect-pts  /media/files/movies_HD/Wall-E_720p_DTS_BluRay.mkv

If you’re like me, you don’t use a frontend to mplayer and prefer to have the terminal output. If so, you can create these little scripts that will pop-up mplayer in a terminal and then use them from the “open with” menu in your favorite file manager:

/usr/local/bin/coreavc-ac3

#!/bin/sh
gnome-terminal -e "mplayer-coreavc -vc coreserver -framedrop -nocorrect-pts -ac hwac3 \"$1\""

/usr/local/bin/coreavc-dts

#!/bin/sh
gnome-terminal -e "mplayer-coreavc -vc coreserver -framedrop -nocorrect-pts -ac hwdts \"$1\""

The -ac options for AC3 or DTS allow for media that has embedded multi-channel audio in either Dolby Digital (AC3) or Sony (DTS) format to go through the digital output of your sound card and directly to a 5.1 surround sound receiver (if you have both a digital out on your sound card and such a receiver).

Conclusions

I made this guide because many of the guides I’ve seen were out of date and the steps I had to undertake spanned multiple websites, blogs and wikis. Keep in mind that if you’re reading this six months from now, this guide is probably out of date itself and there are probably never versions of CoreAVC, coreavc-for-linux and mplayer, all with new an fun interesting bugs that will take you an hour to figure out. If you find any other helpful information, please post a comment.

As far as the actual performance of the CoreAVC codec, it is considerably faster than ffmpeg. There is somewhat of a lag or frame delay effect I see with movies which I don’t see in ffmpeg. I’m guessing this is coming from the directshow server. However with 1080p content, the video decodes much faster and is very smooth without constant bumps and clicks, even when going through the considerable amounts of translation required to run a windows 32-bit native codec in a 64-bit Linux environment.

There are still a couple of artifacts I’ve found and distorted/garbage video during fast motion scenes. This may be due to the codec specific registry settings which I’ll need to play with, or it may be I’m exceeding the limitations of my processor. Your own mileage may vary.

Comments

acmelabs 2009-01-28

Very nice article.

Are you aware of the fact, that a Nvidia 8400GS for about $25 can do hardware decoding of H.264 (HD) content, too?

This is all possible with Nvidia's new driver (180.25) and mplayer.

If you've got a Nvidia 8xxx or above, just use Nvidia's new driver for hardware decoding.

Your description above makes sense for old NVidia cards and current ATI and Intel GFX cards though.

Again, very nice work.

If you are interested, just go to my blog.mymediasystem.net and search for VDPAU.

acmelabs_wth 2009-01-29

acmelabs.... why do you post a crap reply pimping a hardware solution to such a great software article? Think man, think.

acmelabs 2009-01-29

I'm not really sure you really understood this crap. I've been in to CoreAVC for quite a while and most things described above I've already posted in my blog months ago. VDPAU is _the_ big thing at the moment, and it's definitely not about pimping anything, but only _using_ something many systems have already built in. Ppl with Nvidia 8xxx+ GFX cards would go the wrong way using this great docu today. Before November the 14th 2008 (VDPAU release date), it would have made a lot of sense, later than this date, I would really _think_ about it.

Did I feed a troll?

matt 2009-02-17

These instructions are great, except I can not find the correct format for the codecs.conf in any of the comments. I still get the:

This codecs.conf is too old and incompatible with this MPlayer release! at line 1

What do I need to correct in there to get this to work.

Thanks

matt 2009-02-17

I actually got around the issue about (added release 20070930 to the top of the file).

However, when I try to play a file I get: error opening/initializing the selected video_out (-vo) device.

Thanks

Sumit Khanna 2009-02-18

Matt, are you getting that error with the -vo option using the codecs.conf I posted in the instructions? The codecs.conf is the tricky part. I'm hoping that in the next release of coreavc-for-linux, there will be a patch applied to the codecs.conf that it built directly into mplayer itself.

Comments are closed. Why?