So Iâ€™ve been messing around with FFmpeg for AS3/AIR over the past few days and trying to get the thing to compile has been next to impossible. Thereâ€™s no good documentation out there and it seems like weâ€™re the only ones doing it.
So hereâ€™s a little explanation of some of the problems encountered and the basic process to overcome them. Mostly for my future reference but also for any poor soul whoâ€™s been set the task of doing similar.
Compiling FFmpeg with FlasCC/CrossBridge:
One of the important things to note before we get started is that FlasCC needs Java 64 bit to run the compiles properly. Iâ€™d suggest un-installing Java 32bit if you have it as well just to make sure that you donâ€™t get any Path problems but none the less, you need to be using jre 64bit. Iâ€™m using the latest version which is currently jre7, so if all else fails then go back to that version as well.
The second important thing to know is that this process will not work on Windows 8.1, we did it on Windows 8 originally and when trying it on Windows 8.1 it seemed to totally destroy cygwin or FlasCC, none of us could come up with a solution or even find the exact problem but it still works on our Windows 8 laptop.
After youâ€™ve done that you should be good to go.
Create a file on the C drive called â€œffmpegbuildâ€ obviously you can do yours somewhere else but just for ease of following along Iâ€™ll assume youâ€™ve done it this way.
Download the latest ffmpeg snapshot and extract the content into ffmpegbuild/ffmpeg. Itâ€™s important you donâ€™t clone the git repo because this can make changes to line endings.
Download the latest version of FlasCC or CrossBridge (compiled version). Extract it into ffmpegbuild/flascc or ffmpegbuild/crossbridge
Go into your flashcc or crossbridge folder and run the batch file or the shortcut (either works).
Navigate into ffmpegbuild/ffmpeg and run your configure command, this will take a long time. Youâ€™ll need to prefix your configure to look something like this:
PATH=â€/cygdrive/c/Program Files/Java/jre7/bin:/cygdrive/c/Development/ffmpegbuild//flashcc/sdk/usr/bin:$PATHâ€ ./configureâ€¦
Get cup of your drink of choice and wait for it to complete.
Once itâ€™s done you can run your make command, it should look something like this:
Now you can finally run your install command which would look something like this:
PATH=/cygdrive/c/Development/flashcc/sdk/usr/bin:$PATH make install
FFMpeg is now installed and youâ€™re ready to start creating your API for it, we did ours inside ffmpegbuild/src and then would use FlasCC or CrossBridge to run a make command a bit like this:
make FLASCC=/cygdrive/c/Development/ffmpegbuild/flashcc/sdk FLEX=/cygdrive/c/Flex/SDK-Latest/
Our makefile sitting in src was the following and would assume your api is named â€œas3api.câ€, but youâ€™ll have to modify all of that to fit your needs.
T05: check @echo â€œâ€”â€”â€“ build c library â€”â€”â€“â€ @echo && echo â€œNow compile a SWC â€ â€œ$(FLASCC)/usr/bin/gccâ€ as3api_v2.c main.c \ -emit-swc=ffmpeg -o ffmpeg.swc \ -jvmopt -Xmx1500M -jvmopt=-Xmx1G -I â€œ/home/flasccuser/ffmpeg_build/includeâ€ \ -L/home/flasccuser/ffmpeg_build/lib \ -l swresample -lswscale -lavformat -lavcodec -lavutil -lx264 -lfaac #â€$(FLEX)/bin/mxmlcâ€ -static-link-runtime-shared-libraries -compiler.omit-trace-statements=false -library-path=MurmurHash.swc -debug=false swcdemo.as -o swcdemo.swf FLASCC:=X FLEX:=X AS3COMPILER:=asc2.jar BASE_CFLAGS:=-Werror -Wno-write-strings -Wno-trigraphs $?UNAME=$(shell uname -s) ifneq (,$(findstring CYGWIN,$(UNAME))) $?nativepath=$(shell cygpath -at mixed $(1)) $?unixpath=$(shell cygpath -at unix $(1)) else $?nativepath=$(abspath $(1)) $?unixpath=$(abspath $(1)) endif ifneq (,$(findstring â€œasc2.jarâ€,â€$(AS3COMPILER)â€)) $?AS3COMPILERARGS=java $(JVMARGS) -jar $(call nativepath,$(FLASCC)/usr/lib/$(AS3COMPILER)) -merge -md else echo â€œASC is no longer supportedâ€ ; exit 1 ; endif check: @if [ -d $(FLASCC)/usr/bin ] ; then true ; \ else echo â€œCouldnâ€™t locate FLASCC sdk directory, please invoke make with \â€make FLASCC=/path/to/FLASCC/sdk â€¦\â€â€ ; exit 1 ; \ fi @if [ -d â€œ$(FLEX)/binâ€ ] ; then true ; \ else echo â€œCouldnâ€™t locate Flex sdk directory, please invoke make with \â€make FLEX=/path/to/flex â€¦\â€â€ ; exit 1 ; \ fi clean: rm -f *.swf *.swc *.bc *.exe
I hope this helps someone in the future, sadly it isn't the detailed write up I'd like to be able to do. However most of this was me fumbling my way through things and powering through.
Subscribe to Elliot Blackburn
Get the latest posts delivered right to your inbox