FFmpeg for iOS5 - ios

Has anyone been able to compile ffmpeg libraries using the iOS5 sdk? I have found scripts that use the 4.3 sdk but nothing for iOS5. I would assume that libraries built with the old sdk and armv7 will still be compatible for iOS 5.
Here is the command I am trying to use:
./configure \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \ --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system \ --target-os=darwin \ --arch=arm \ --cpu=cortex-a8 \ --extra-cflags='-arch armv7' \ --extra-ldflags='-arch armv7' \ --prefix=compiled/armv7 \ --enable-pic \ --enable-cross-compile \ --disable-armv5te \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-ffprobe \ --disable-doc
I have also tried using a script like this one:
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7' --enable-pic
make
mv libavcodec/libavcodec.a armv7/
mv libavdevice/libavdevice.a armv7/
mv libavformat/libavformat.a armv7/
mv libavutil/libavutil.a armv7/
mv libswscale/libswscale.a armv7/
rm lib/*.a
cp armv7/*.a lib/
I have also tried to switch to the gcc-4.2 as well as the llvm-gcc-4.2. However I get an "Unknown option" error shown below in the comments.
Any info will be great and thanks.

UPDATED: Completely changed the answer to use the script that I use.
You will also need to download gas-preprocessor.pl from https://github.com/yuvi/gas-preprocessor, put it in your path and make it executable.
Then create a script (say make_for_iphone.sh) and put this in it:
export PLATFORM="iPhoneOS"
export MIN_VERSION="4.0"
export MAX_VERSION="5.0"
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${MAX_VERSION}.sdk
export CC=$DEVROOT/usr/bin/llvm-gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/llvm-g++
export AR=$DEVROOT/usr/bin/ar
export LIBTOOL=$DEVROOT/usr/bin/libtool
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
COMMONFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -isysroot ${SDKROOT} -marm -fPIC"
export LDFLAGS="${COMMONFLAGS} -fPIC"
export CFLAGS="${COMMONFLAGS} -fvisibility=hidden"
export CXXFLAGS="${COMMONFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden"
FFMPEG_LIBS="libavcodec libavdevice libavformat libavutil libswscale"
echo "Building armv6..."
make clean
./configure \
--cpu=arm1176jzf-s \
--extra-cflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
--extra-ldflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION}' \
--enable-cross-compile \
--arch=arm \
--target-os=darwin \
--cc=${CC} \
--sysroot=${SDKROOT} \
--prefix=installed \
--disable-network \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-devices \
--disable-parsers \
--disable-encoders \
--disable-protocols \
--disable-filters \
--disable-bsfs \
--enable-decoder=h264 \
--enable-decoder=svq3 \
--enable-gpl \
--enable-pic \
--disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3
mkdir -p build.armv6
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv6/; done
echo "Building armv7..."
make clean
./configure \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
--extra-ldflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION}' \
--enable-cross-compile \
--arch=arm \
--target-os=darwin \
--cc=${CC} \
--sysroot=${SDKROOT} \
--prefix=installed \
--disable-network \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-devices \
--disable-parsers \
--disable-encoders \
--disable-protocols \
--disable-filters \
--disable-bsfs \
--enable-decoder=h264 \
--enable-decoder=svq3 \
--enable-gpl \
--enable-pic \
--disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3
mkdir -p build.armv7
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv7/; done
mkdir -p build.universal
for i in ${FFMPEG_LIBS}; do lipo -create ./build.armv7/$i.a ./build.armv6/$i.a -output ./build.universal/$i.a; done
for i in ${FFMPEG_LIBS}; do cp ./build.universal/$i.a ./$i/$i.a; done
make install
This compiles both armv6 and armv7 versions and puts them into a fat library using lipo. It installs to a folder underneath where you run the script from called installed.
Note that at the moment I've had to turn off inline assembly using a perl inline replace to change HAVE_INLINE_ASM from 1 to 0. This is because of this problem with gas-preprocessor.pl - https://github.com/yuvi/gas-preprocessor/issues/16.
Also note that this has turned off all encoders, decoders, muxers, demuxers, etc except for the H264 decoder. Just change the configure lines to compile what you want for your use case.
Please remember also that this has enabled GPL code - so you should be aware about what that means for iPhone apps. If you're not aware then you should do some reading about that.

Here is my working Configure for cross-compiling FFmpeg on iOS 6 the arch is ARMv7
NOTE: You must have to have gas-preprocessor.pl inside /usr/local/bin/ please do not continue until you have gas-preprocessor.pl on your bin directory
Download FFmpeg 1.0 "Angel" from here
Unzip it and place it somewhere i.e. your Desktop folder
Open terminal and browse to unzipped FFmpeg folder
Copy and paste the following command, (be patient will take a while)
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --enable-pic --enable-decoder=rawvideo --disable-asm
Now type the following command on terminal make (wait a little more)
Once it has finished now type on terminal sudo make install (wait again)
Go to /usr/local/lib to find your freshly baked armv7 libs
Enjoy!
Alex

I've created an "ffmpeg4ios" project at https://github.com/ciphor/ffmpeg4ios, which is successfully compiled on iOS 5.0.
You can check it.

Related

Compile FFMPEG in iOS with bitcode mode

I compiled FFMPEG libs which supports for iOS 7 and 8 but since recent release with iOS 9 there is a new feature has issued which called bitcode mode , as a default setting , this setting has set to NO .
But if i set this as yes , following error will execute ,
libavdevice.a(avfoundation.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
Is there any way to compile FFMPEG which supports FFMpeg in bitcode enabled mode
here is the build script i used
#!/bin/sh
# directories
SOURCE="ffmpeg-2.6.2"
FAT="FFmpeg-iOS"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
#X264=`pwd`/fat-x264
#FDK_AAC=`pwd`/fdk-aac/fdk-aac-ios
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic"
if [ "$X264" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
if [ "$FDK_AAC" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libfdk-aac"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
if [ ! `which yasm` ]
then
echo 'Yasm not found'
if [ ! `which brew` ]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" \
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
if [ ! `which gas-preprocessor.pl` ]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \
-o /usr/local/bin/gas-preprocessor.pl \
&& chmod +x /usr/local/bin/gas-preprocessor.pl) \
|| exit 1
fi
if [ ! -r $SOURCE ]
then
echo 'FFmpeg source not found. Trying to download...'
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
|| exit 1
fi
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if [ "$X264" ]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
if [ "$FDK_AAC" ]
then
CFLAGS="$CFLAGS -I$FDK_AAC/include"
LDFLAGS="$LDFLAGS -L$FDK_AAC/lib"
fi
TMPDIR=${TMPDIR/%\/} $CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$THIN/$ARCH" \
|| exit 1
make -j3 install $EXPORT || exit 1
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
echo Done
I got it working using the following CONFIGURE_FLAGS:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic \
--extra-cflags=-fembed-bitcode --extra-cxxflags=-fembed-bitcode"
If you only need to decode videos, you should add more flags to disable all muxers,encoders. You'll also probably don't need filters. This will save some space. I also disabled the ARCH i386, which is not needed for the iOS simulator.
I use these flags for my project:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic \
--extra-cflags=-fembed-bitcode --extra-cxxflags=-fembed-bitcode \
--enable-nonfree --enable-gpl \
--disable-ffserver --disable-ffmpeg --disable-ffprobe \
--disable-avdevice --disable-avfilter --disable-encoders \
--disable-parsers --disable-decoders --disable-protocols \
--disable-filters --disable-muxers --disable-bsfs \
--disable-indevs --disable-outdevs --disable-demuxers \
--enable-protocol=file \
--enable-protocol=tcp \
--enable-protocol=udp \
--enable-decoder=msmpeg4v3 \
--enable-decoder=mpeg4 \
--enable-decoder=mjpeg \
--enable-decoder=h264 \
--enable-parser=mpeg4video \
--enable-parser=mjpeg \
--enable-parser=h263 \
--enable-parser=h264 \
--enable-parser=aac \
--enable-demuxer=aviĀ \
--enable-demuxer=mov \
--enable-demuxer=rtsp \
"
Add -fembed-bitcode-marker to CONFIGURE_FLAGS
like this:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic -fembed-bitcode-marker"

Error when I compile ffmpeg in Xcode5

I compile ffmpeg in OSX. My xcode version is 5.1. ffmpeg configure is :
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/usr/bin/gcc ' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk' --enable-pic --disable-asm --prefix="../lib"
This is the error:
/usr/bin/ranlib: object: libavfilter/libavfilter.a(aeval.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make: *** [libavfilter/libavfilter.a] Error 1
I'm not sure what this error means or how to solve it.
I see you are trying to build it for ARM, therefore iOS...
It's not that simple... run this script here... if you uncomment X264 you can compile it with libx264, if you need that, I can send you the other script later.
#!/bin/sh
# directories
SOURCE="ffmpeg-2.3"
FAT=`pwd`/"fat"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
#X264=`pwd`/../x264/fat
CONFIGURE_FLAGS="--enable-cross-compile \
--disable-debug \
--disable-programs \
--disable-doc \
--enable-pic \
--enable-cross-compile \
--target-os=darwin \
--enable-nonfree \
--enable-gpl \
--enable-static \
--disable-shared \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm"
if [ "$X264" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7s armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
if [ ! `which yasm` ]
then
echo 'Yasm not found'
if [ ! `which brew` ]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" \
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
if [ ! `which gas-preprocessor.pl` ]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(curl -3L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \
-o /usr/local/bin/gas-preprocessor.pl \
&& chmod +x /usr/local/bin/gas-preprocessor.pl) \
|| exit 1
fi
if [ ! -r $SOURCE ]
then
echo 'FFmpeg source not found. Trying to download...'
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
|| exit 1
fi
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if [ "$X264" ]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
$CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$THIN/$ARCH" \
|| exit 1
make -j3 install $EXPORT || exit 1
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
echo Done

Compile FFmpeg with librtmp ERROR: librtmp not found

Environment: Mac OS X 10.9.2, Xcode 5.1.
I have compiled librtmp, libogg and libspeex successfully, they are in the directories named fat-librtmp, fat-libogg and fat-libspeex , then I run the shell script as below to coompile them into FFmpeg:
#!/bin/sh
# OS X Mavericks, Xcode 5.1
set -ex
VERSION="2.2.2"
CURRPATH=`pwd`
DSTDIR="ffmpeg-built"
SCRATCH="scratch"
LIBRTMP=$CURRPATH/librtmp
ARCHS="i386 x86_64 armv7 armv7s arm64"
CONFIGURE_FLAGS="--enable-shared \
--disable-doc \
--disable-stripping \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-ffprobe \
--disable-decoders \
--disable-encoders \
--disable-protocols \
--enable-protocol=file \
--enable-protocol=rtmp \
--enable-librtmp \
--enable-encoder=flv \
--enable-decoder=flv \
--disable-symver \
--disable-asm \
--enable-cross-compile"
rm -rf $DSTDIR
mkdir $DSTDIR
if [ ! `which yasm` ]; then
if [ ! `which brew` ]; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
fi
brew install yasm
fi
if [ ! `which gas-preprocessor.pl` ]; then
curl -3L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl -o /usr/local/bin/gas-preprocessor.pl
chmod +x /usr/local/bin/gas-preprocessor.pl
fi
if [ ! -e ffmpeg-$VERSION.tar.bz2 ]; then
curl -O http://www.ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
fi
tar jxf ffmpeg-$VERSION.tar.bz2
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
for ARCH in $ARCHS; do
mkdir -p $DSTDIR/$SCRATCH/$ARCH
cd $DSTDIR/$SCRATCH/$ARCH
CFLAGS="-arch $ARCH"
if [ $ARCH == "i386" -o $ARCH == "x86_64" ]; then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=6.0"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=6.0"
if [ $ARCH == "arm64" ]; then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CFLAGS="$CFLAGS -I$LIBRTMP/include"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS -L$LIBRTMP/lib"
$CURRPATH/ffmpeg-$VERSION/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix=$CURRPATH/$DSTDIR/$ARCH
make -j3 install $EXPORT
cd $CURRPATH
done
rm -rf $DSTDIR/$SCRATCH
mkdir -p $DSTDIR/lib
cd $DSTDIR/$ARCH/lib
LIBS=`ls *.a`
cd $CURRPATH
for LIB in $LIBS; do
lipo -create `find $DSTDIR -name $LIB` -output $DSTDIR/lib/$LIB
done
cp -rf $DSTDIR/$ARCH/include $DSTDIR
for ARCH in $ARCHS; do
rm -rf $DSTDIR/$ARCH
done
Unluckily, the config.log shows:
check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
pkg-config --exists --print-errors librtmp
Package librtmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `librtmp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'librtmp' found
ERROR: librtmp not found
I have googled and knew that configure contains a line enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket, which maybe be wrong. Right? Can somebody help me to solve it?
UPDATE at 2014/06/10
I think it's about pkgconfig or something, so I have create a file named librtmp.pc at /usr/local/lib/pkgconfig, which contains below text:
prefix=/usr/local/librtmp
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: librtmp
Description: RTMP implementation
Version: v2.3
Requires:
URL: http://rtmpdump.mplayerhq.hu
Libs: -L${libdir} -lrtmp -lz
Cflags: -I${includedir}
Also I have moved built librtmp to /usr/local. After above being done, I run the shell script again, but still same error! Can somebody told me why and how to solve it?
The below links give some insight while building ffmpeg.
https://trac.ffmpeg.org/wiki/CompilationGuide/Generic
Check whether LD_LIBRARY_PATH environment variable is set properly.

Specified sample format s16 is invalid or not supported

I am encoding PCM data to AAC format using ffmpeg:
Following is my code to setup the context object:
-(id)encode:(short*)data{
AVCodecContext *audioCodec;
AVCodec *codec;
avcodec_register_all();
//Set up audio encoder
codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
if (codec == NULL){
NSLog(#"no codec");
}
audioCodec = avcodec_alloc_context3(codec);
audioCodec->strict_std_compliance = -2;
audioCodec->bit_rate = 64000;
audioCodec->sample_fmt = AV_SAMPLE_FMT_S16;
audioCodec->sample_rate = 8000;
audioCodec->channels = 2;
audioCodec->profile = FF_PROFILE_AAC_MAIN;
audioCodec->time_base = (AVRational){1, 8000};
audioCodec->codec_type = 1;
if (avcodec_open2(audioCodec, codec, NULL)) {
NSLog(#"could not open codec");
}
return #"NO";
}
I always get an error log as :
aac # 0x151cda00] Specified sample format s16 is invalid or not supported
If I don't provide any sample format, I get the same log:
aac # 0x151cda00] Specified sample format -1 is invalid or not supported
and that's why avcodec_open2() gives log of could not open codec ;
Can some 1 tell me what is the issue?
ffmpeg compilation script is as follows:
#!/bin/sh
# directories
SOURCE="ffmpeg"
FAT="fat"
VERSION="2.0.2"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
#X264=`pwd`/fat_x264
CONFIGURE_FLAGS="--enable-cross-compile \
--disable-network \
--disable-encoders \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-protocols \
--disable-devices \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-iconv \
--disable-bzlib \
--disable-mmx \
--disable-mmxext \
--disable-amd3dnow \
--disable-amd3dnowext \
--disable-sse \
--disable-sse2 \
--disable-sse3 \
--disable-sse4 \
--disable-avx \
--disable-fma4 \
--disable-swresample \
--disable-postproc \
--disable-bsfs \
--disable-filters \
--disable-asm \
--disable-yasm \
--disable-debug \
--disable-doc \
--disable-armv5te \
--disable-armv6 \
--disable-armv6t2 \
--enable-protocol=file \
--enable-avformat \
--enable-avcodec \
--enable-swscale \
--enable-demuxer=mp3 \
--enable-demuxer=aac \
--enable-demuxer=image2 \
--enable-demuxer=mov \
--enable-decoder=rawvideo \
--enable-demuxer=h263 \
--enable-demuxer=h264 \
--enable-decoder=mp3 \
--enable-decoder=aac \
--enable-decoder=mjpeg \
--enable-decoder=h263 \
--enable-decoder=h264 \
--enable-decoder=mpeg4 \
--enable-encoder=mp3 \
--enable-encoder=aac \
--enable-encoder=mjpeg \
--enable-encoder=h263 \
--enable-encoder=h264 \
--enable-encoder=mpeg4 \
--enable-parser=mp3 \
--enable-parser=aac \
--enable-parser=h264 \
--enable-pic"
if [ "$X264" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7s armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if [ "$X264" ]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
$CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$THIN/$ARCH"
make -j3 install $EXPORT
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
I was having a similar issue as I did not know what format my Windows Phone supported. (turns out it was AV_SAMPLE_FMT_FLTP )
I ended up looking at the avcodec_open2 source code (https://www.ffmpeg.org/doxygen/2.1/libavcodec_2utils_8c_source.html)
And discovered it was referencing the codec to see which samples were supported.
With that in mind you can do something like this:
audioCodec->sample_fmt = audioCodec->codec->sample_fmts[0];
Maybe the error is misleading.
Try removing the line:
audioCodec->profile = FF_PROFILE_AAC_MAIN or changing it to audioCodec->profile = FF_PROFILE_UNKNOWN
Try compiling in the fdk-aac encoder: https://github.com/mstorsjo/fdk-aac The output quality is much better and it supports a wide range of sample rates and bitrates. To my knowledge, the native ffmpeg encoder is not very good in comparison. But maybe you can't use fdk-aac because of the license (you will need to pay patent royalties to Fraunhofer):
http://www.vialicensing.com/licensing/aac-faq.aspx
http://www.vialicensing.com/licensing/aac-fees.aspx

How to use/create the FFmpeg library [duplicate]

I'm trying to compile the ffmpeg by using the make and build files in iFrameExtractor example. firstly i tried to follow the readme file on the github, which only says to run the ./build_universal in ffmpeg folder. it did not work
i then tried to follow the info in INSTALL without success. i then tried doing the stuff in INSTALL followed by the ./build_universal which didn't work. All the *.a files that are imported to the project exists until the end of the build sequence. when the lipo commands in build_universal are run, which i guess concat the .a files for the different architectures(?). anyhow these leave the following errors:
lipo: specifed architecture type (armv6) for file (armv6/libavcodec.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavdevice.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavformat.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavutil.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libswscale.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
i can get the project to compile for simulator if i only use ./build_armv7 but if i run the universal the .a files are removed in the end. and only using doesn't work to build for iphone 4 .
After a week of trial and error, I was finally able to create the ffmpeg universal libraries and successfully compile and run iFrameExtractor for the device as well as the simulator.
To compile and run the project on your iPhone device OR simulator:
1) open Terminal
2) clone the repository: git clone git://github.com/lajos/iFrameExtractor.git
3) go to the ffmpeg folder in the project: cd iFrameExtractor/ffmpeg
4) run: ./configure
5) Edit the build scripts (build_armv6, build_armv7, build_i386) as follows:
These scripts assume you are using iOS SDK 5.0 on Xcode 4.2.
build_armv6:
#!/bin/tcsh -f
if (! -d armv6) mkdir armv6
if (! -d lib) mkdir lib
rm armv6/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--enable-cross-compile --target-os=darwin \
--arch=arm --cpu=arm1176jzf-s \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags="-arch armv6 -L//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
--extra-cflags="-arch armv6"
make
mv libavcodec/libavcodec.a armv6/
mv libavdevice/libavdevice.a armv6/
mv libavformat/libavformat.a armv6/
mv libavutil/libavutil.a armv6/
mv libswscale/libswscale.a armv6/
rm lib/*.a
cp armv6/*.a lib/
build_armv7:
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--enable-cross-compile --target-os=darwin \
--arch=arm --cpu=cortex-a8 --enable-pic \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags="-arch armv7 - L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
--extra-cflags="-arch armv7"
make
mv libavcodec/libavcodec.a armv7/
mv libavdevice/libavdevice.a armv7/
mv libavformat/libavformat.a armv7/
mv libavutil/libavutil.a armv7/
mv libswscale/libswscale.a armv7/
rm lib/*.a
cp armv7/*.a lib/
build_i386:
#!/bin/tcsh -f
if (! -d i386) mkdir i386
if (! -d lib) mkdir lib
rm i386/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk \
--extra-ldflags="-arch i386 -L//Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system" \
--extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
make
mv libavcodec/libavcodec.a i386/
mv libavdevice/libavdevice.a i386/
mv libavformat/libavformat.a i386/
mv libavutil/libavutil.a i386/
mv libswscale/libswscale.a i386/
rm lib/*.a
cp i386/*.a lib/
6) build the ffmpeg libraries: ./build_universal
7) open the xcode project and run it on your iPhone device or simulator
These steps work perfectly for me. I hope this will help others struggling to get the ffmpeg libraries working for iOS.
i downloaded the latest ffmpeg repository and used the following to compile only for armv6 and armv7. I couldn't get it working for i386, i receive errors that the cputype and subcputype are wrong. apparently the cputype is supposed to be x86 and subcputype should be intel.
anyhow i used the following build scripts to compile for the arm architectures:
build script:
#!/bin/sh
set -e
SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) )
DIST_DIR_BASE=${DIST_DIR_BASE:="$SCRIPT_DIR/dist"}
if [ -d ffmpeg ]
then
echo "Found ffmpeg source directory, no need to fetch from git..."
else
echo "Fetching ffmpeg from git://git.videolan.org/ffmpeg.git..."
git clone git://git.videolan.org/ffmpeg.git
fi
ARCHS=${ARCHS:-"armv6 armv7"}
for ARCH in $ARCHS
do
FFMPEG_DIR=ffmpeg-$ARCH
if [ -d $FFMPEG_DIR ]
then
echo "Removing old directory $FFMPEG_DIR"
rm -rf $FFMPEG_DIR
fi
echo "Copying source for $ARCH to directory $FFMPEG_DIR"
cp -a ffmpeg $FFMPEG_DIR
cd $FFMPEG_DIR
DIST_DIR=$DIST_DIR_BASE-$ARCH
mkdir -p $DIST_DIR
case $ARCH in
armv6)
EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s"
EXTRA_CFLAGS="-arch $ARCH"
EXTRA_LDFLAGS="-arch $ARCH"
;;
armv7)
EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=cortex-a8 --enable-pic"
EXTRA_CFLAGS="-arch $ARCH"
EXTRA_LDFLAGS="-arch $ARCH"
;;
x86_64)
EXTRA_CC_FLAGS="-mdynamic-no-pic"
;;
esac
echo "Configuring ffmpeg for $ARCH..."
./configure \
--prefix=$DIST_DIR \
--extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/system \
--disable-bzlib \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \
--extra-ldflags="$EXTRA_LDFLAGS" \
--extra-cflags="$EXTRA_CFLAGS" \
$EXTRA_FLAGS
echo "Installing ffmpeg for $ARCH..."
make && make install
cd $SCRIPT_DIR
if [ -d $DIST_DIR/bin ]
then
rm -rf $DIST_DIR/bin
fi
if [ -d $DIST_DIR/share ]
then
rm -rf $DIST_DIR/share
fi
done
and combine libs script:
#!/bin/bash
set -e
ARCHS="armv6 armv7"
for ARCH in $ARCHS
do
if [ -d dist-$ARCH ]
then
MAIN_ARCH=$ARCH
fi
done
if [ -z "$MAIN_ARCH" ]
then
echo "Please compile an architecture"
exit 1
fi
OUTPUT_DIR="dist-uarch"
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/lib $OUTPUT_DIR/include
for LIB in dist-$MAIN_ARCH/lib/*.a
do
LIB=`basename $LIB`
LIPO_CREATE=""
for ARCH in $ARCHS
do
if [ -d dist-$ARCH ]
then
LIPO_CREATE="$LIPO_CREATE-arch $ARCH dist-$ARCH/lib/$LIB "
fi
done
OUTPUT="$OUTPUT_DIR/lib/$LIB"
echo "Creating: $OUTPUT"
lipo -create $LIPO_CREATE -output $OUTPUT
lipo -info $OUTPUT
done
echo "Copying headers from dist-$MAIN_ARCH..."
cp -R dist-$MAIN_ARCH/include/* $OUTPUT_DIR/include
then i import the .a files from BUILD-FOLDER/dist-uarch and it builds in xcode like a charm!
building FFMPEG for iOS 5.1
hope this will help you to build latest FFMPEG for iOS 5.1
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./build_universal
note: you have to create build_* scripts first, to do this see code below
script for ARMV7 - create file build_armv7
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' --enable-pic
make
mv libavcodec/libavcodec.a armv7/
mv libavdevice/libavdevice.a armv7/
mv libavformat/libavformat.a armv7/
mv libavutil/libavutil.a armv7/
mv libswscale/libswscale.a armv7/
rm lib/*.a
cp armv7/*.a lib/
script for ARMV6 - create file build_armv6
#!/bin/tcsh -f
if (! -d armv6) mkdir armv6
if (! -d lib) mkdir lib
rm armv6/*.a
make clean
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --cpu=arm1176jzf-s --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk'
make
mv libavcodec/libavcodec.a armv6/
mv libavdevice/libavdevice.a armv6/
mv libavformat/libavformat.a armv6/
mv libavutil/libavutil.a armv6/
mv libswscale/libswscale.a armv6/
rm lib/*.a
cp armv6/*.a lib/
script for simulator - create file build_i386
#!/bin/tcsh -f
if (! -d i386) mkdir i386
if (! -d lib) mkdir lib
rm i386/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \
--extra-ldflags="-arch i386 -L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system" \
--extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
make
mv libavcodec/libavcodec.a i386/
mv libavdevice/libavdevice.a i386/
mv libavformat/libavformat.a i386/
mv libavutil/libavutil.a i386/
mv libswscale/libswscale.a i386/
rm lib/*.a
cp i386/*.a lib/
script for universal build (will merge libraries into one universal) - create file build_universal
#!/bin/tcsh -f
source ./build_armv6
source ./build_armv7
source ./build_i386
if (! -d universal) mkdir universal
if (! -d lib) mkdir lib
rm universal/*.a
lipo -create -arch armv6 armv6/libavcodec.a -arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -output universal/libavcodec.a
lipo -create -arch armv6 armv6/libavdevice.a -arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -output universal/libavdevice.a
lipo -create -arch armv6 armv6/libavformat.a -arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -output universal/libavformat.a
lipo -create -arch armv6 armv6/libavutil.a -arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -output universal/libavutil.a
lipo -create -arch armv6 armv6/libswscale.a -arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -output universal/libswscale.a
rm lib/*.a
cp universal/*.a lib/

Resources