Jon Simpson’s Weblog

My personal space for ideas & information.

VC-1/WMV9 on Mac OS X/PowerPC

Windows Media Video 9 (WMV9) has been the root of many issues for Mac users in dealing with media playback for a long while now. Due to its prevalence on people’s desktop computers, a lot of small video clips that float around the web often carry the .wmv extension, and the playback of these files is something that should ‘just work’. You’d think it would, especially given that Microsoft produce a copy of Windows Media Player for Mac OS X that ’supports’ this format. But that isn’t the whole story…

Windows Media Player for the Mac can decode streams of WMV9 video, but it cannot handle the format in an AVI container. Unfortunately, a lot of video files out there use WMV9 video streams with MP3 or other audio streams, a combination that is out of spec for a .WMV file and the official Windows Media Player for OS X will point blank refuse to play these files.

On Windows, programs like mplayer and VLC can use native DLL hooking on the codec.dll’s that ship with windows and decode these video streams without having open source decoders for them. This approach also works on x86 Linux, if the owner of the system obtains those .dll files from a Windows PC or elsewhere. When we come to the Mac (or PPC Linux for that matter..), the .dll’s wont work because they’re compiled for x86, so hooking them isn’t an option. You can see that this format is pretty much inaccessible at this point on a Mac.

Enter Microsoft’s VC-1 standardization push, to have WMV9 certified as a video standard for use on next generation HD-DVD’s. In renaming the WMV9 format VC-1 for general use, and submitting technical documentation and a reference decoder, Microsoft finally gave the world a chance to explore and decode WMV9 streams using platforms other than x86. The SMPTE used to offer a copy of the reference decoder to those willing to hand over an e-mail address and name (this appears to have stopped now, and I’m not sure what the current state of restrictions on getting hold of the reference decoder from SMPTE is).

Good news is that recently a patch and other support code has been created to allow the SMPTE reference decoder to be used by FFmpeg, a powerful open source multimedia library used by several players, most notably mplayer. I think you can see where I’m going with this, and hence, some makefile poking around and adjustment later, I have a copy of mplayer built that can decode WMV9 video streams on Mac OS X PowerPC. The decoder runs quite slow (at least it did on the 120fps source media I had lying around to test it on), so its rather handy that along with mplayer, mencoder also uses the decoder, allowing you to transcode from the WMV9 video direct to Xvid, losing as little quality as possible and creating a Mac/PPC compatible file.

Just to prove the point, here’s mplayer decoding one of the Windows Media 10 trailers at 1280×720, 720p HD (I half-sized the video window).

Note that this really wasn’t running at anything near realtime, probably more like 1/2 to 1/3 realtime. Obviously the main application for this slow, but accurate decoder is for transcoding, and thats certainly what I’d do with any WMV9 content that I wanted to watch with it. At 320×240 the decoder can just about keep up if it drops frames (and this is on a 1.67ghz PowerBook) so that should give you some idea of the speed.

Being able to work with WMV9 streams on the Mac (conversion, and limited playback capabilities) has been something I’d been wanting to do for a long time, as it was another reason to have a Windows PC lying around. With the advent of the x86 Intel Mac, its possible that no solution could have emerged before the whole situation became a non issue, as .dll hooking will work on the new Intel Macs, allowing them to play back these kinds of streams.

Previous: Compiling MPlayer on Mac OS X Tiger Next: Compiling mplayer-cvs on Mac OS X 10.4 Tiger

7 Comments

  1. fred says:

    The link above lists instructions for modifying the build of ffmpeg; it’s a little unclear how to modify the mplayer cvs build as detailed in your next post to include this patch….

  2. Luca says:

    Hi, how did you make it work for you? I followed your instructions to build mplayer from cvs and it works fine, but I cannot add wmv3 support. Compilation goes fine, but no playback.
    Thinking I could have done something wrong, I then tried building ffmpeg itself, but again I get no errors and no decoder. :-(

    When I run “./ffmpeg -formats | grep wmv3″ I get this (empty) output:
    FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
    configuration:
    libavutil version: 49.0.0
    libavcodec version: 51.1.0
    libavformat version: 50.0.0
    built on Feb 7 2006 12:24:08, gcc: 4.0.1 (Apple Computer, Inc. build 5250)

    Is there something which must be done that is not mentioned in the other blog?

    Thank you

  3. Jon says:

    I’ve purposely avoided detailing the exact step by step process I used to use the SMPTE VC-1 with mplayer, because I’m not really sure about the legal issues surrounding the use of the VC-1 code.

    I’ll see what I can do about getting together a few pointers or something that can at lesat point you guys in the right direction.

  4. Luca says:

    Hi,

    I could successfully make it work ;-)… “Use the source, Luke”… it was an easy fix, afterall.

    Now I have an issue: you say that you could re-encode the files with a different codec. I have done it with the XVID one, but the files I obtain take 100% of my CPU and mplayer can’t play them. I have tried many options (1 pass encoding, 2 pass encoding, fixed bitrate…) but I always get the same results. I know this is not a mencoder forum (I already tried them, btw…) but could you share the settings you used to re-encode the files? That shouldn’t violate any law. :-)

    If you could do it, I’d greately appreciate it.

    Thanks!

  5. a says:

    With the advent of the x86 Intel Mac, its possible that no solution could have emerged before the whole situation became a non issue, as .dll hooking will work on the new Intel Macs, allowing them to play back these kinds of streams.

    Sorry, am not terribly savvy. Does that mean that I could then simply install, say, MPlayer or VLC (without having to compile it myself, find codecs, etc) and be able to view wmv9 video?

  6. Jon says:

    a, I’m not exactly sure of the implementation details, but certainly on x86, the .dll files that contain Windows Media decoders from windows should be able to be called from mplayer like they can on Linux and Windows. Whether additional work is required to make this work on OS X, or whether it will work with a plain build would be something interesting to see.

  7. Banana says:

    argh!
    I can understand nearly all the instructions, just a few little bits I don’t understand!

    “edit libavcodec/vc9.c, go the very end of the file, and add #if 0/#endif around the wmv3_decoder AVCodec structure; this will keep it from conflicting with the new SMPTE WMV3 decoder” I couldn’t understand this, so I just commented out the wmv3_decoder stuff with a /* stuff */

    it all works good, starts compiling, but errors out at “cc -Wl,-dynamic,-search_paths_first -g -o ffmpeg_g ffmpeg.o cmdutils.o -L./libavcodec/libvc1 -lvc1 -L./libavformat -lavformat -L./libavcodec -lavcodec(BUILDSUF) -L./libavutil -lavutil -lz
    /bin/sh: -c: line 1: syntax error near unexpected token `(’
    /bin/sh: -c: line 1: `cc -Wl,-dynamic,-search_paths_first -g -o ffmpeg_g ffmpeg.o cmdutils.o -L./libavcodec/libvc1 -lvc1 -L./libavformat -lavformat -L./libavcodec -lavcodec(BUILDSUF) -L./libavutil -lavutil -lz ‘”

    can anyone help?

    Thanks

Leave a Reply