FFmpeg with FlasCC/CrossBridge
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
ffmpegbuildobviously 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.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/mxml -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.