Hooking Up The SMPTE VC-1 Decoder In FFmpeg

Update, Jan-16-2008: I should have posted this update a long time ago. Readers should be advised that these instructions are obsoleted by the fact that FFmpeg already includes a native (and much faster) VC-1 decoder.

Some people have asked me for my code to make the SMPTE VC-1 reference decoder work with FFmpeg, slow though it may be. I suppose I could make a patch. But the official version of FFmpeg is whatever happens to be in CVS at the current moment. So any patch I could produce would work for maybe a day. So get ready to do a little editing on your local FFmpeg CVS tree. The steps:

  1. procure the VC1_reference_decoder_release6.zip file from the main site and unzip the tree somewhere
  2. have a copy of FFmpeg’s CVS tree handy; the rest of these instructions will assume that you are sitting in the root of the FFmpeg tree
  3. create a directory called libavcodec/libvc1
  4. copy all of the *.c and *.h files from VC1_reference_decoder_release6/decoder/ into libavcodec/libvc1/
  5. copy all of the *.c and *.h files from VC1_reference_decoder_release6/shared/ into libavcodec/libvc1/
  6. place the libvc1-makefile.txt into libavcodec/libvc1/Makefile
  7. change directory into libavcodec/libvc1 and type ‘make’
  8. change directory back to the FFmpeg root
  9. place the smpte-vc1.c file into libavcodec/
  10. 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
  11. edit libavcodec/Makefile and add smpte-vc1.o to the end of the OBJS list
  12. edit the top-level Makefile and add “-L./libavcodec/libvc1 -lvc1” (without the quotes) to FFLIBS
  13. run ‘./configure’ at the top level if you have not already done so for this tree
  14. run ‘make’ at the top level

That should be all there is to it. If FFmpeg declines to acknowledge the ability to decode WMV3 data run ‘./ffmpeg -formats | grep wmv3’ and make sure you see (after the versioning info): ” D V wmv3″.

Remember, the performance of the SMPTE VC-1 decoder is, as they say, “nothing to write home about”. It’s dog slow. It’s not meant to be fast. And it will not be optimized. Ever. Eventually, we will create our own decoder that leverages optimized VLC decoding functions, transforms, filters, etc. But in the meantime, if you want to experiment with the reference decoder, this should work for you.

Update, Feb-16-2006: Thanks to Richard Goodwin for pointing out step 12.5: edit libavcodec/allcodecs and remove the comment blocks around “register_avcodec(&wmv3_decoder);”. Sometime between the original post and now, this was commented out due to the fact that the native WMV3 decoder is not classified as “working” yet.

Psssst… Do you need a copy of vc1_reference_decoder_release6.zip? Try here. Remember– slow as all get out. If you’re going to use it, may it be for the purpose of creating a free and fast implementation.