Some blurbs about tweaking mplayer’s codecs

This post was written by eli on December 11, 2009
Posted Under: Linux,Software

The (non-) problem

The truth is that there never was a problem. What really happened was that I got things confused between a few versions of mplayer/mencoder, and only the latests (of those I have, 1.0rc1-3.2.2) does the job. Bus since I wrote down some things I might want to return to some day, here’s the whole blob.

What got me on this, was that using mplayer (version 1.0 of some rc’s) to play my Canon 500D’s movie clips, I get the sound OK, but an image which flashes the real thing every now and then (keyframes?) and shows some grey garbage otherwise. And tons of error messages on the console.

On some other version the image looks OK, but A/V sync is lost soon enough. And many error messages indicate that the decoder doesn’t get it right (a lot of “Consumed only 136509 bytes instead of 1365120″ alikes). That isn’t very promising.

It’s worth to note, that mplayer/mencoder choose the native ffmpeg libavcodec by default. As ffmpeg improves, these issues are fixed.

My real goal is to convert the clip to something descent using mencoder. I don’t even think about editing a video in H.264. So all I need now is to find the right video decoder.

But I prefer to use the decoder supplied by Canon (spoiler: I never managed to). Since I own the camera, and got the software legally, why not use the codec they sent me? Only one problem…

What is the DLL of the codec used?

In order to “steal” the codec from the Canon application, I needed to know which DLL Canon uses to play its own videos. In order to do that, I opened Zoombrowser, and ran the ListDLL command line utility (which can be downloaded from here). The utility spits out all DLLs of all processes running, but using the “>” redirection in a command window, all data goes to a file. Then I double-clicked a video, and ran ListDLL again, redirecting the data to another file.

The difference between the files is most probably the DLLs loaded to play a clip. This worked because I ran Zoombrowser from scratch.

With my favourite diff application, I got a long list of new DLLs. These two caught my eyes:

C:\Program Files\Canon\Canon MOV Decoder\
C:\Program Files\Canon\Canon MOV Decoder\CanonIPPH264DecLib.dll

Hmmm…  In retrospective, I could have figured that one out without heavy tools. But at least I know which they are now.

Installing the codec

I copied both files mentioned above to /usr/local/lib/win32. Then I added the following entry to the /usr/local/etc/mplayer/codecs.conf:

videocodec canonh264
  info "Canon's H.264 decoder"
  status working
  fourcc avc1,AVC1
  fourcc h264,H264
  fourcc x264,X264
  driver dshow
  dll ""
  guid 0xb7215ee3, 0xaf54, 0x433f, 0x9d, 0x2f, 0x22, 0x64, 0x91, 0x69, 0x84, 0xf6
  out YUY2
  out BGR32,BGR24,BGR15

As for the output formats, I guessed them. Odds are I got it wrong.  As for the GUID, I managed to find a class with a “FriendlyName” saying “Canon H.264 Decode Filter 1.3″, and it has the class ID B7215EE3-AF54-433F-9D2F-2264916984F6. So basically that’s it.

Anyhow, this didn’t work at all. When I ran mencoder with -vc canonh264, it ended with

Forced video codec: canonh264
Opening video decoder: [dshow] DirectShow video codecs
Called unk_GetVersionExW
Segmentation fault

I won’t even try to pretend that I understand what went wrong here, but GetVersionExW happens to be a function exported from Windows’ kernel32.dll, retrieving information about the current operating system. I’m not clear on whether the function was never found, or if the decoder wasn’t happy with the answer it got. This way or another, a segfault is a segfault. I thought this was the place to give up. I’ll use the good old ffmpeg decoder.

A remark about H.264

Canon’s choice of H.264 as the encoding format is a bit bizarre, since it’s a version of MPEG-4. And just for general knowledge: MPEG-4 is horrible. In particular it has this annoying thing about stale regions in the frame, which look bad and basically don’t heal. But I suppose that MPEG-2 would require too fast writes to the flash or something. The result is still pretty bad.


Trying to fix video issues late at night is not necessarily the wisest thing to do.

Reader Comments

I got a Canon SX1 IS. It makes Full HD Movies, but this movies do not run smoothly on every PC i had tried. It got some drop frames. So i tried do use other codecs. With FDDShow i got no sound, but smooth video. When i got sound, i got drop frames.

SO i started looking into Canon CD and found this But i have no idea on how to use it.

At this time i have a camera with Full HD movies that a can´t watch. And got no solution yet. So i have to agree that this codec used by Canon is bizarre.

Ps. My PCs are an Core 2 Duo 2.somethink MHz with 2 GB running WXP 32 bits and now W7 64 bits and an Athlon 64 X2 2.somethink MHz with 4 GB running XWP 64 bits.

Written By Daniel Quirino on June 8th, 2010 @ 13:10

This post is about how to make mplayer adapt Canon’s codecs.

Anyhow, I would convert the videos to a friendlier format, such as DivX. I use mencoder, but you may prefer a more GUI-oriented application. I can’t help you much on this one.

Written By eli on June 8th, 2010 @ 13:19

Add a Comment

required, use real name
required, will not be published
optional, your blog address