I want to take a video that I’ve recorded with UIImagePickerController and feed it to OpenCV. The video gets saved on the device at some weird temp location like [file://localhost/private/var/mobile/App-…-dvideo.MOV](file://localhost/private/var/mobile/Applications/117BE734-F718-49C3-B80A-19C0E29B7785/tmp/capture-T0x105250.tmp.XGORHP/capturedvideo.MOV) as H.264, 640 x 480, AAC, Mono, 44.100 kHz.
The problem is that OpenCV is pretty picky about video formats and doesn’t know what to do with H264.
I know that I could go with the ofVideoPlayer-on-iphone??, but I’d really just like to get OpenCV compiling with FFMPEG. It should be easy!
I can compile both them separately just fine.
This puts the FFMPEG stuff into /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr so it can be found by anything being cross-compiled for iPhoneOS4.0.sdk
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure \
--prefix='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr' \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 \
--as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1' \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk \
--enable-cross-compile \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--enable-pic \
--disable-ffmpeg
make
and then ‘sudo make install’
And then, from: the-directions-from-the-mplayer-forums, I got the gas-preprocessor and:
wget [http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.0/OpenCV-2.0.0.tar.bz2](http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.0/OpenCV-2.0.0.tar.bz2)
tar -xvf OpenCV-2.0.0.tar.bz2
cd OpenCV-2.0.0
export CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1
export CC=${CXX}
export CXXFLAGS='-miphoneos-version-min=4.0 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk'
export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
export CXXCPP=${CPP}
./configure --prefix='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr' \
--build=i686-apple-darwin \
--host=arm-apple-darwin10 \
--target=arm-apple-darwin10 \
--enable-static \
--disable-shared \
--disable-sse \
--disable-apps \
--without-python \
--without-1394libs \
--without-v4l \
--without-imageio \
--with-ffmpeg \
--without-carbon \
--without-gtk \
--without-gthread
(Why does cross-compiling need to be different for every package?)
But every time, configure gives me the following:
checking ffmpeg/avcodec.h usability... no
checking ffmpeg/avcodec.h presence... no
checking for ffmpeg/avcodec.h... no
checking libavcodec/avcodec.h usability... yes
checking libavcodec/avcodec.h presence... no
configure: WARNING: libavcodec/avcodec.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: libavcodec/avcodec.h: proceeding with the compiler's result
checking for libavcodec/avcodec.h... yes
checking ffmpeg/avformat.h usability... no
checking ffmpeg/avformat.h presence... no
checking for ffmpeg/avformat.h... no
checking libavformat/avformat.h usability... yes
checking libavformat/avformat.h presence... no
configure: WARNING: libavformat/avformat.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: libavformat/avformat.h: proceeding with the compiler's result
checking for libavformat/avformat.h... yes
checking for library containing avcodec_decode_video... no
What the hell does that mean? “accepted by the compiler, rejected by the preprocessor!”
and at the end:
Video I/O ---------------------
Use QuickTime / Mac OS X: no
Use xine: no
Use gstreamer: no
Use ffmpeg: no
Use dc1394 & raw1394: no
Use dc1394_v2 & raw1394: no
Use v4l: no
Use v4l2: no
Use unicap: no
Bah. A little help, pretty please?