Feb 15
Building ffmpeg to support Windows Media files
Update: 8/11/06
Multimedia Mike msged me to say:
“I just wanted to point out that it may be helpful to amend that post to note that the current SVN copy of FFmpeg contains a native VC-1 decoder; no more painful hack to get the slooooow reference decoder working”
So hop on over to his site for more information
—
This post is for uber geeks, so move on if that’s not you
While using Gallery 2.1 for my photo gallery I finally got around to start uploading movie files as well as pictures. Being lazy, and wanting a small, compatible file type that most of my family could play, I opted to use Windows Movie Maker to output .wmv files. They come out pretty small, with great quality, and anyone on Windows (and some Mac/Linux users) can play them.
Well, lo and behold, the Gallery uses the ffmpeg module for generating thumbnails of the video files, and the current ffmpeg builds/CVS can’t handle later versions of Windows Media encoded (wmv3/wmv8/wmv9) video. Luckily, I was able to find a hack for it that got me going, and I’m re-posting it here for posterity (and when I lose my binaries and need to build them again).
(Caveat: my web host allows compilation from source; yours may not, and you may be out of luck if so. Unfortunately the binary I built is for x86_64 and probably not useful to many so I am not going to post it here.)
Hooking Up The SMPTE VC-1 Decoder In FFmpeg
Filed under:
Open Source Multimedia — Multimedia Mike @ 5:22 pmSome 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:
- procure the VC1_reference_decoder_release6.zip file from the main site and unzip the tree somewhere
- 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
- create a directory called libavcodec/libvc1
- copy all of the *.c and *.h files from VC1_reference_decoder_release6/decoder/ into libavcodec/libvc1/
- copy all of the *.c and *.h files from VC1_reference_decoder_release6/shared/ into libavcodec/libvc1/
- place the libvc1-makefile.txt into libavcodec/libvc1/Makefile
- change directory into libavcodec/libvc1 and type ‘make’
- change directory back to the FFmpeg root
- place the smpte-vc1.c file into libavcodec/
- 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- edit libavcodec/Makefile and add smpte-vc1.o to the end of the OBJS list
- edit the top-level Makefile and add “-L./libavcodec/libvc1 -lvc1″ (without the quotes) to FFLIBS
- run ‘./configure’ at the top level if you have not already done so for this tree
- run ‘make’ at the top level
Now, there’s also a magic step 12.5 that I had to do, which was edit the libavcodec/allcodecs.c and uncomment the section about wmv3. If you don’t, the wmv3 support won’t get compiled and this will all be for naught!
Big thanks to merbanan on #ffmpeg (irc.freenode.net) for assistance with getting this going!
I’ve also linked the reference decoder zip file locally if you can’t find it anymore…
Technorati Tags: ffmpeg, gallery, photos


February 17th, 2006 at 9:39 am
Note for anyone who may have tripped on it:
11. edit the top-level Makefile and add “-L./libavcodec/libvc1 -lvc1″ (without the quotes) to FFLIBS
This is a bit fuzzy — here’s what it should look like:
FFLIBS = -L./libavformat -lavformat$(BUILDSUF) -L./libavcodec -lavcodec$(BUILDSUF) -L./libavutil -lavutil$(BUILDSUF) -L./libavcodec/libvc1 -lvc1$(BUILDSUF)
February 17th, 2006 at 1:09 pm
Hi, I wrote the original post. Thanks for keeping me honest. The problem is that between then and now, the FFmpeg team disabled the original, highly experimental native WMV3 decoder. I have updated my post to reflect this.
February 25th, 2006 at 11:22 pm
Hello!
I am build mplayer this codec. Hm… for normal perfomance need -O2 or -O3(and some flags) in Makefile. Hm… Many clips play good but big move print error:
WMV3 init
VC-1: Initializing with 6 bytes of extradata
8F 1C 1A 01 40 2F
FATAL ERROR:
FATAL ERROR: Image too big for all levels
vc1DEC_DecoderRequirements() failed
Could not open codec.
VDecoder init failed
February 26th, 2006 at 6:09 pm
Error profile(2) in struct:
{ /* Reserved Profile */
{ 0, 0, 0, 0, vc1_MVRange64_32 },
},
null struckt… hm…
March 4th, 2006 at 6:32 pm
To build this with mplayer, after configure is done edit config.mak
AV_DEP = libavcodec/libavcodec.a libavcodec/libvc1/libvc1.a libavformat/libavformat.a libavutil/libavutil.a libavcodec/libpostproc/libpostproc.a
AV_LIB = libavcodec/libavcodec.a libavcodec/libvc1/libvc1.a libavformat/libavformat.a libavutil/libavutil.a libavcodec/libpostproc/libpostproc.a
then edit ~/.mplayer/codecs.conf
videocodec ffwmv3
info “FFmpeg M$ WMV3/WMV9″
## status crashing
status working
fourcc WMV3,wmv3
driver ffmpeg
dll wmv3
out YV12,I420,IYUV
March 20th, 2006 at 1:14 am
Hi, I made it through most of the compiling, but came across a snag that I cannot get past.
I added all of the appropriate hacks and edits, but when I recompile ffmpeg, I get the following:
make[1]: Leaving directory `/dir/ffmpeg/libavformat’
gcc -Wl,–warn-common -rdynamic -g -o ffmpeg_g ffmpeg.o cmdutils.o -L./libavformat -lavformat -L./libavcodec -lavcodec -L./libavutil -lavutil -L./libavcodec/libvc1 -lvc1 -lm -lfaad -lfaac -lmp3lame -lz
/usr/bin/ld: cannot find -lvc1
collect2: ld returned 1 exit status
Can anyone help out with why the library would not be found?
Thanks for any help!
March 21st, 2006 at 10:18 am
I’m getting an undefined reference to fseeko in qt-faststart.c when I try and do my final make.
I’m not a c programmer. Can anyone help?
March 21st, 2006 at 5:04 pm
Anonymous,
Did you do what Scott Free said regarding editing the top level makefile?
March 21st, 2006 at 9:29 pm
I did I followed the instructions word for word (this is great tutorialy by the way… thanks). And I am still getting the error.
Here is more info from above
make -C libavutil all
make[1]: Entering directory `/home/user/src/ffmpeg/libavutil’
make[1]: Nothing to be done for `all’.
make[1]: Leaving directory `/home/user/src/ffmpeg/libavutil’
make -C libavcodec all
make[1]: Entering directory `/home/user/src/ffmpeg/libavcodec’
make[1]: Nothing to be done for `all’.
make[1]: Leaving directory `/home/user/src/ffmpeg/libavcodec’
make -C libavformat all
make[1]: Entering directory `/home/user/src/ffmpeg/libavformat’
make[1]: Nothing to be done for `all’.
make[1]: Leaving directory `/home/user/src/ffmpeg/libavformat’
gcc -Wl,–warn-common -rdynamic -g -o ffmpeg_g ffmpeg.o cmdutils.o -L./libavformat -lavformat -L./libavcodec -lavcodec -L./libavutil -lavutil -L./libavcodec/libvc1 -lvc1 -lm -lfaad -lfaac -lmp3lame -lz
/usr/bin/ld: cannot find -lvc1
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
It’s so frustrating because I know I am so close, and I just can’t figure out this last part does any one know where -/lvc1 is supposed to be located?
March 23rd, 2006 at 12:51 am
I kind of got this working, but ffmpeg is trying to use wmv2 instead of wmv3 on wmv3 files (ie. version 9 files). Any suggestions?
March 23rd, 2006 at 9:16 am
ok, update: this works for wmv version 9 files. Version 8 files, I’m not having success with, but I believe ffmpeg is using the native codecs and not the one introduced here.
March 26th, 2006 at 6:32 pm
Hey hongg,
On step 6 do you create a directory called Makefile, or do you add the text from the libvc1-makefile.txt into in the file to the makefile that is already located in that directory.
Thanks!
March 26th, 2006 at 10:00 pm
It means copy that file to a file named Makefile in the specified directory
March 27th, 2006 at 4:51 am
Can you make your binary available for public download? (even if it is outdated!)
*I can provide you with a mirror*
March 27th, 2006 at 5:00 am
As of the 27th march 2006 - ffmpeg doesnt seem to support wmv3 at all - therefore the following steps :
# 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
# edit libavcodec/Makefile and add smpte-vc1.o to the end of the OBJS list
# edit the top-level Makefile and add “-L./libavcodec/libvc1 -lvc1″ (without the quotes) to FFLIBS
# run ‘./configure’ at the top level if you have not already done so for this tree
# run ‘make’ at the top level
wont even work with the latest cvs release of ffmpeg.
This is the error you will receive after following the steps to the exact.
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o allcodecs.o allcodecs.c
allcodecs.c: In function `avcodec_register_all’:
allcodecs.c:94: error: `wmv3_decoder’ undeclared (first use in this function)
allcodecs.c:94: error: (Each undeclared identifier is reported only once
allcodecs.c:94: error: for each function it appears in.)
make[1]: *** [allcodecs.o] Error 1
anyone have any ideas how i can implement it?
March 27th, 2006 at 11:39 am
Andy: Read the step 12.5 in the original post (the original point of the post).
March 27th, 2006 at 1:19 pm
hi,
I ve read the instructions I ve done as follewed and i got proper msgs. Everthing builded nice, no errors durning ‘make’, i have also added wmv to formats with
“./ffmpeg -formats | grep wmv3″ (D V wmv3 poped up). But even every step of installation seemed to be done well i get same msg durning convertion wmv to any other format…(unsupported codec (id=74) for input stream #0.1). Any ideas?
March 27th, 2006 at 4:08 pm
Sorry for spam, i just wanted to add screenshot of an error: http://www.patrz.pl/error.jpg
March 30th, 2006 at 4:53 am
Hi,
I’m new to ffmpeg, I want to know can I use ffmpeg to build software like goldzsoft? avi mpeg splitter joiner
March 30th, 2006 at 6:07 pm
I got the thing to work on a Linux RedHat 9 box, however when I convert WM3 to any other format it scrolls the “decoding frame x” (where x is current frame) for every frame, and it’s a bit annoying. Is there any way to disable that?
March 31st, 2006 at 1:04 pm
Another question. For some reason adding “-title” paramater and supplying title does absolutely nothing no matter what format I create. Anyone know why this may be?
Thanks,
Luc L.
March 31st, 2006 at 7:23 pm
Anyone want to send me a rpm of this thing working? I am in the process of moving so i don’t have the time to do it yet. Anyone want to email the rpm to chris@active9.com, please.
April 4th, 2006 at 6:41 pm
Luc: 1st answer: Yes, you can disable the “decoding frame x” message. Just open the smpte-vc1.c file, search for that string, and comment out that line.
2nd (non-)answer: I don’t know. The -title sort of depends on what format you are converting to.
April 19th, 2006 at 12:47 pm
Hi there.
I’m trying to compile this on OS X — I think I’ve followed the directions properly, but I’m getting linking errors at the end…
ld: Undefined symbols:
_vc1DECBIT_InitialiseBitstream
_vc1DEC_DecodeFrame
_vc1DEC_DecodeSequence
_vc1DEC_DecoderInitialise
_vc1DEC_DecoderRequirements
/usr/bin/libtool: internal link edit command failed
make[1]: *** [libavcodec.dylib] Error 1
make: *** [lib] Error 2
Any idea as to where I should look?
-NJS
April 19th, 2006 at 1:22 pm
NitricJerkSud: Try following the instructions, starting at step 1. You obviously did not build the VC-1 library, or are not linking it to the rest of the project.
April 19th, 2006 at 4:07 pm
I’m having problems compiling wmv2 files
following error:
“J-type picture is not supported”
How can I force versions
April 19th, 2006 at 4:10 pm
Ok previous post I posted a “smaller then sign”, seems like a bug in this comment system ( not escaping special HTML chars )
so to complete my post:
How can I force versions “smaller then sign” 3 to decode with this codec?
April 19th, 2006 at 6:23 pm
MultimediaMike:
I managed to get it working, but had to add a -L../libavcodec/libvc1 to the ‘extra-ldflags’ parameter, and -lvc1 to the ‘extra-libs’ parameter.
ffmpeg compiled cleanly… But now I have an ffmpeg that doesn’t support WMA2. Am I missing something? Is this part of the standard? Or can I only convert movies with WMV3, and another, supported audio format?
-NJS.
April 25th, 2006 at 5:36 pm
Interesting article but did you notice that the reference decoder software you mirrored now costs $400 according to http://www.smpte.org/smpte_store/test_materials/?
http://www.smpte.org/smpte_store/test_materials/VC-1_Reference_License.pdf seems to forbid distribution of source code
May 4th, 2006 at 3:10 am
“and anyone on Windows (and some Mac/Linux users) can play them.”
Or you could just used avi or mpeg or whatever, wich ALL Max/Linux users can play
May 4th, 2006 at 1:29 pm
Hi,
If you wish, you can download Gentoo ebuild from here:
http://brcha.free.fr/files/ebuilds/ffmpeg/ffmpeg-0.4.9_p20060302-r1.ebuild
“and anyone on Windows (and some Mac/Linux users) can play them.”
or can be able to transcode it using ffmpeg2theora to a normal format (Ogg/Theora) that anybody can use!
May 9th, 2006 at 6:19 am
Works like a charm, but one problem though.
I wanted to use ffmpeg with wmv3 support ffmpeg-php.
After following the steps and compiling ffmpeg with –enable-shared, ffmpeg-php bails out with the following message
PHP Warning: Unknown(): Unable to load dynamic library
‘/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’ -
/usr/local/lib/libavcodec.so.51: undefined symbol:
vc1DECBIT_InitialiseBitstream in Unknown on line 0
I am not sure if this is entirely related to ffmpeg-php..
If so, i apologise for putting this up on the wrong forum.
I have tried googling for the same but my efforts so far have taken me nowhere.
Any pointers/suggestions welcome.
Thanks.
May 14th, 2006 at 12:57 pm
FrobCs all you gotta do is instead of the ffmpeg-php library use the system command.
system(”ffmpeg arguments here”);
works like a charm.
May 21st, 2006 at 9:52 pm
Can you upload a file “ffmpeg.exe”?
May 26th, 2006 at 4:52 am
Thanks Chris,
Invoking ffmpeg externally always worked like a charm. I just wanted to use ffmpeg-php library.
However, i have droppped the idea of ffmpeg-php for now.
May 27th, 2006 at 5:55 am
Hi!
Thanks for an excellent tutorial!
This worked like a charm, except that the converted movie did not contain any sound (the original video did).
Is this a known problem?
This is the command line I’m using:
ffmpeg-wmv9 -i “$1″ -ab 56 -ar 22050 -b 500 -r 15 -s 320×240 “$2″
Where $1 is the input and $2 is the output file.
Any hints appreciated!
Cheers
May 28th, 2006 at 5:06 pm
Hi, i want to know if it is possible to encode to the wmv9 format with this hack? Or is it only for decoding? Did anyone know how to encode to wmv9 with ffmpeg on a linux machine?
Thanks
June 18th, 2006 at 1:06 am
I put all this together into a handy tar file, ready to compile, with the modified FFMPEG source and the VC-1 source all included:
http://steamymobile.com/downloads
I even put up ready-compiled Linux binaries.
Getting all this stuff to work is not completely trivial, so this may be an easier way.
June 28th, 2006 at 7:20 am
I have managed to integrate vc1 with ffmpeg but when i try to use the codec i get the following message
WMV3 init
VC-1: Initializing with 0 bytes of extradata
FATAL ERROR:
FATAL ERROR: DecoderRequirements: Unable to read PROFILE bits
vc1DEC_DecoderRequirements() failed
could not open codec
Any Ideas ?
Oz
July 19th, 2006 at 8:00 am
I got this error every time:
~/ffmpeg/framegrabber/ffmpeg$ ./ffmpeg -i sss.wmv
FFmpeg version HEAD, Copyright (c) 2000-2004 Fabrice Bellard
configuration:
libavutil version: 49.0.0
libavcodec version: 51.9.0
libavformat version: 50.4.0
built on Jul 19 2006 15:57:10, gcc: 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
WMV3 init
VC-1: Initializing with 4 bytes of extradata
4E 41 1A 01
FATAL ERROR: Assert 0 == (Height & 3) failed at line 397 file vc1tools.c
July 26th, 2006 at 12:57 pm
I did any step by step and everything works fine, but when I try to run ffmpg to decode a WMV3 to FLV i get the following message:
Unsoported codec (id=74) for input stream #0.1
What I did wrong? or What I need to do?
September 6th, 2006 at 2:45 am
[...] 支持wmv9 VC1_reference_decoder_release6 http://www.richardgoodwin.com/wp/2006/02/15/building-ffmpeg-to-support-windows-media-files [...]
September 13th, 2006 at 12:20 am
Hello,
i am new in this field. and i would like to do convert video files to flash.
I already download this .zip flie but i cant’ get how it will configure in my server.
Any one can give me the idea.
Thanks
September 13th, 2006 at 12:24 am
Hello,
i am new in video streaming. i want to convert all video file into flash.
I already download .zip file from here but i can’t get how to install it in my server.
Plz anyone can help me how can i install or configure.
Thanks
September 25th, 2006 at 12:41 am
Hi,
The latest version of FFMpeg dose not have the libavcodec/vc9.c file and the main Makefile format is also differet.
Do you kindly guide me how to proceed the process to latest one? or you can provide some reference website?
Thank you!
November 17th, 2006 at 12:49 pm
the latest ffmpeg now has native wmv3 support, SO ALL THOSE USING GOOGLE TO FIND THIS PAGE, THIS PAGE IS OUTDATED!
just compile ffmpeg svn to get wmv3 support.
January 16th, 2008 at 10:25 am
[...] 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 [...]
January 30th, 2008 at 9:29 am
Hi,
this is very use full for me. but I am not able to configure with the ffmpeg will you b plz. give me a full configured zip file or send me a detail mail for configutation.
configured file is most wellcome, because I try lot to configure.
thank’s in Advanced.