IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用

最近在研究IOS视频播放器,需要使用到ffmpeg4ios,所以整理编译过程。

需要使用到Git,Linux Shell脚本执行install-ffmpeg.sh即可。

下述Linux Shell脚本下载地址:http://ishare.iask.sina.com.cn/f/37135883.html

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
复制代码

 

编译出来的文件为:

libavcodec.a

用于各种类型声音/图像编解码;

libavdevice.a

libavfilter.a

libavformat.a  

用于各种音视频封装格式的生成和解析,包括获取解码所需信息以生成解码上下文结构
和读取音视频帧等功能;

libavutil.a

包含一些公共的工具函数;

libswscale.a

用于视频场景比例缩放、色彩映射转换;

libx264.a

 

开源示例iFrameExtractor

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

这是一个iOS下利用ffmpeg解码播放的例子。不过这个例子是利用贴图的方式来显示,效果不是很好,而且没有加入声音解码。

 

要想项目顺利运行需要添加支持库

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

  • libbz.dylib
  • libz.dylib
  • libiconv.2.4.0.dylib

 

修改头文件搜索路径(头文件下载地址:http://www.ffmpeg4ios.org/releases/ffmpeg4ios-1.0-include.zip)

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

 

修改库文件搜索路径(编译出来.a文件的路径)

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

深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
【5层】公司办公楼全套设计+++(3156平,含计算书、建筑图,结构图、实习报告,PKPM,答辩PPT) 1、资源项目源码已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值