IOS ffmpeg For SDK6.1 compiler, simulator, armv7, armv7s can use

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Recent research on IOS video player, need to use ffmpeg4ios, so make the compilation process.

Need to use Git, Linux Shell script execution can be install-ffmpeg.sh.

The Linux Shell script to download address:

install-ffmpeg.sh

SRCDIR=`pwd`
VERSION="1.2.1"

echo "install gas-* perl script"
./install-gas.sh

echo "download ffmpeg"
set -e
if [ ! -e ffmpeg-${VERSION}.tar.bz2 ]; then
    echo "Downloading ffmpeg-${VERSION}.tar.bz2"
    curl -O  http://ffmpeg.org/releases/ffmpeg-${VERSION}.tar.bz2
else
    echo "Using ffmpeg-${VERSION}.tar.bz2"
fi

tar jxvf ffmpeg-${VERSION}.tar.bz2


echo "copy install shell script to ffmpeg"
cp ./compile-*.sh "ffmpeg-${VERSION}"
cd "ffmpeg-${VERSION}"

if [ -d x264 ]
    then
        (cd $SRCDIR/ffmpeg-${VERSION}/x264; git pull)
    else
        git clone git://git.videolan.org/x264.git x264
fi

echo "compile armv7s ..."
./compile-armv7s.sh

echo "compile armv7 ..."
./compile-armv7.sh

echo "compile i386 for Simulator ..."
./compile-i386.sh

echo "packaging universal version ..."
./compile-universal.sh

install-gas.sh

echo "install gas-preproccesor.pr"
git clone git://github.com/mansr/gas-preprocessor.git

echo "copy gas-preprocessor.pl to /usr/sbin"
sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/

echo "set execute right"
chmod +x /usr/sbin/gas-preprocessor.pl

echo "install finished."

compile-armv7s.sh

SRCDIR=`pwd`
SDKVERSION="6.1"

cd $SRCDIR/x264

make clean

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    ./configure \
        --host=arm-apple-darwin \
        --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \
        --prefix=build/armv7s \
        --extra-cflags='-arch armv7s' \
        --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system -arch armv7s" \
        --enable-pic --disable-shared --enable-static

make && make install

cd $SRCDIR

make clean

./configure \
    --prefix=armv7s \
    --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/iPhoneOS${SDKVERSION}.sdk \
    --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system \
    --target-os=darwin \
    --arch=arm \
    --cpu=cortex-a9 \
    --extra-cflags='-I./x264/build/armv7s/include -arch armv7s' \
    --extra-ldflags='-L./x264/build/armv7s/lib -arch armv7s' \
    --enable-pic \
    --enable-cross-compile \
    --enable-gpl \
    --enable-libx264 \
    --disable-ffmpeg  \
    --disable-ffplay \
    --disable-ffserver \
    --disable-doc
        



# build for armv7s
make clean
make

# copy out the armv7s libs
mkdir -p ./build/armv7s
cp -f ./libavcodec/libavcodec.a ./build/armv7s/libavcodec.a
cp -f ./libavdevice/libavdevice.a ./build/armv7s/libavdevice.a
cp -f ./libavfilter/libavfilter.a ./build/armv7s/libavfilter.a
cp -f ./libavformat/libavformat.a ./build/armv7s/libavformat.a
cp -f ./libavutil/libavutil.a ./build/armv7s/libavutil.a
cp -f ./libswscale/libswscale.a ./build/armv7s/libswscale.a

compile-armv7.sh

SRCDIR=`pwd`
SDKVERSION="6.1"

cd $SRCDIR/x264

make clean

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    ./configure \
        --host=arm-apple-darwin \
        --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \
        --prefix=build/armv7 \
        --extra-cflags='-arch armv7' \
        --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system -arch armv7" \
        --enable-pic --disable-shared --enable-static

make && make install

cd $SRCDIR

make clean

./configure \
    --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/iPhoneOS${SDKVERSION}.sdk \
    --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system \
    --target-os=darwin \
    --arch=arm \
    --cpu=cortex-a8 \
    --extra-cflags='-I./x264/build/armv7/include -arch armv7' \
    --extra-ldflags='-L./x264/build/armv7/lib -arch armv7' \
    --enable-pic \
    --enable-cross-compile \
    --enable-gpl \
    --enable-libx264 \
    --disable-ffmpeg  \
    --disable-ffplay \
    --disable-ffserver \
    --disable-doc
        



# build for armv7
make clean
make

# copy out the armv7 libs
mkdir -p ./build/armv7
cp -f ./libavcodec/libavcodec.a ./build/armv7/libavcodec.a
cp -f ./libavdevice/libavdevice.a ./build/armv7/libavdevice.a
cp -f ./libavfilter/libavfilter.a ./build/armv7/libavfilter.a
cp -f ./libavformat/libavformat.a ./build/armv7/libavformat.a
cp -f ./libavutil/libavutil.a ./build/armv7/libavutil.a
cp -f ./libswscale/libswscale.a ./build/armv7/libswscale.a

compile-i386.sh

SRCDIR=`pwd`
SDKVERSION="6.1"

cd $SRCDIR/x264

echo "compile x264 i386 ..."

make clean

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \
    ./configure \
        --host=i386-apple-darwin \
        --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk \
        --prefix=build/i386 \
        --extra-cflags='-arch i386' \
        --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/lib/system -arch i386" \
        --enable-pic --disable-shared --enable-static --disable-asm

make && make install

cd $SRCDIR

echo "compile ffmpeg i386 ..."

make clean

./configure \
    --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \
    --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' \
    --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk \
    --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/lib/system \
    --target-os=darwin \
    --arch=i386 \
    --cpu=i386 \
    --extra-cflags='-I./x264/build/i386/include -arch i386' \
    --extra-ldflags='-L./x264/build/i386/lib -arch i386' \
    --enable-pic \
    --enable-cross-compile \
    --enable-gpl \
    --enable-libx264 \
    --disable-ffmpeg  \
    --disable-ffplay \
    --disable-ffserver \
    --disable-doc \
    --disable-asm


# build for i386
make clean
make

# copy out the i386 libs
mkdir -p ./build/i386

cp -f ./libavcodec/libavcodec.a ./build/i386/libavcodec.a
cp -f ./libavdevice/libavdevice.a ./build/i386/libavdevice.a
cp -f ./libavfilter/libavfilter.a ./build/i386/libavfilter.a
cp -f ./libavformat/libavformat.a ./build/i386/libavformat.a
cp -f ./libavutil/libavutil.a ./build/i386/libavutil.a
cp -f ./libswscale/libswscale.a ./build/i386/libswscale.a

compile-universal.sh

# make fat (universal) libs
xcrun -sdk iphoneos lipo -output ./build/libavcodec.a  \
    -create \
        -arch armv7s ./build/armv7s/libavcodec.a \
        -arch armv7 ./build/armv7/libavcodec.a \
        -arch i386 ./build/i386/libavcodec.a

xcrun -sdk iphoneos lipo -output ./build/libavdevice.a  \
    -create \
        -arch armv7s ./build/armv7s/libavdevice.a \
        -arch armv7 ./build/armv7/libavdevice.a \
        -arch i386 ./build/i386/libavdevice.a

xcrun -sdk iphoneos lipo -output ./build/libavfilter.a  \
    -create \
        -arch armv7s ./build/armv7s/libavfilter.a \
        -arch armv7 ./build/armv7/libavfilter.a \
        -arch i386 ./build/i386/libavfilter.a

xcrun -sdk iphoneos lipo -output ./build/libavformat.a  \
    -create \
        -arch armv7s ./build/armv7s/libavformat.a \
        -arch armv7 ./build/armv7/libavformat.a \
        -arch i386 ./build/i386/libavformat.a

xcrun -sdk iphoneos lipo -output ./build/libavutil.a  \
    -create \
        -arch armv7s ./build/armv7s/libavutil.a \
        -arch armv7 ./build/armv7/libavutil.a \
        -arch i386 ./build/i386/libavutil.a

xcrun -sdk iphoneos lipo -output ./build/libswscale.a  \
    -create \
        -arch armv7s ./build/armv7s/libswscale.a \
        -arch armv7 ./build/armv7/libswscale.a \
        -arch i386 ./build/i386/libswscale.a

xcrun -sdk iphoneos lipo -output ./x264/build/libx264.a  \
    -create \
        -arch armv7s ./x264/build/armv7s/lib/libx264.a \
        -arch armv7 ./x264/build/armv7/lib/libx264.a \
        -arch i386 ./x264/build/i386/lib/libx264.a

The compiled file:

libavcodec.a

Used for various types of audio / video codec,

libavdevice.a

libavfilter.a

libavformat.a  

For the generation and analysis of a variety of audio and video format, including access to decode the information needed to generate decoded context structure

And read audio and video frames and other functions,

libavutil.a

Contains some public utility functions,

libswscale.a

Video scene scaling for color conversion, mapping,

libx264.a


Open source iFrameExtractor example

git clone git://github.com/lajos/iFrameExtractor.git

This is the use of ffmpeg decoding example of a iOS. But this example is the use of mapping way to display, the effect is not very good, but did not join the voice decoding.


To project success need to add support library

Project References -> Targets -> Build Phases -> Link Binary With Librarys


Modify header file search path (a header file download address: http://www.ffmpeg4ios.org/releases/ffmpeg4ios-1.0-include.zip)

Project References -> Targets -> Build Settings -> Header Search Paths


Modifying the library file search path (compiled from the path of the.A file)

Project References -> Targets -> Build Settings -> Library Search Paths  


Questioning can leave a message

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Carter at November 30, 2013 - 5:00 AM