一、 调试环境准备
Xcode版本:Xcode 4.6.2
确保xcode的Command Line Tools已安装, Command Line Tools位于Xcode->Perference->Downloads目录下
确保git工作正常, 安装xcode后,在Terminal里git应该就可以正常工作了, 如果工作不正常,可以到下面的链接下载gitfor mac:http://code.google.com/p/git-osx-installer/
二、 下载代码
.下载ffmpeg源代码
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
参考:http://ffmpeg.org/download.html
下载ffmpeg-iphone-build
git clone https://github.com/gabriel/ffmpeg-iphone-build.git
参考:https://github.com/gabriel/ffmpeg-iphone-build
三、 编译
拷贝ffmpeg-iphone-build/gas-preprocessor.pl到 /usr/sbin目录下
/usr/sbin目录在文件夹为当前窗口,上方工具栏选择前往-》前往文件夹输入路径即可。
编译ffmpeg for armv7
(1) 将新下载的ffmpeg拷贝到ffmpeg-iphone-build目录下,改名为ffmpeg-armv7
(2) 用TextEdit打开build-armv7文件
(3) 将build-armv7修改成
#!/bin/sh
trap exit ERR
FFMPEG_DIR=ffmpeg-armv7
SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) )
echo "Pulling r22403..."
# svn co -r22403 svn://svn.ffmpeg.org/ffmpeg/trunk $FFMPEG_DIR
cd $FFMPEG_DIR
mkdir -p dist
# Default configure options
CONFIGURE_OPTIONS="--enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-cross-compile --enable-nonfree --disable-armv5te --disable-swscale-alpha --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-debug"
# Add x264 if exists
X264_DIST="$SCRIPT_DIR/x264-armv7/dist"
if [ -d "$X264_DIST" ]; then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-libx264 --extra-ldflags=-L$X264_DIST/lib --extra-cflags=-I$X264_DIST/include"
fi
# Add xvid if exists
XVID_DIST="$SCRIPT_DIR/xvid-armv7"
if [ -d "$XVID_DIST" ]; then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-libxvid --extra-ldflags=-L$XVID_DIST/lib --extra-cflags=-I$XVID_DIST/include"
fi
echo "Configure options: $CONFIGURE_OPTIONS"
./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='$SCRIPT_DIR/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.1.sdk \
--extra-ldflags='-arch armv7 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk' \
--prefix=compiled/armv7 \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' $CONFIGURE_OPTIONS
make && make install
echo "Installed: $FFMPEG_DIR/dist"
5)在Terminal里运行 ./build-armv7
把省城的lib**.a和头文件拷贝到示例工程,示例工程源码iFrameExtractor (git clone git://github.com/lajos/iFrameExtractor.git)
添加libbz2.1.0.dylib,libiconv.dylib,libz.dylib,
添加Header Search Paths:"$(SRCROOT)/lib/libavcodec"
添加Library Search Oaths :"$(SRCROOT)"
如果得不到视频源分辨率pCodecCtx->height;改成pCodecCtx->coded_width;
测试地址@"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov?tcp"
网络地址最后添加?tcp.
工程需要修改
左边选中工程,中间选中target,右面选中Build settings,在Architectures选项卡里面选择
Architetures为Optimized(armv7),Base SDK为Latest iOS(iOS 4.3) Valid Architectures填写armv7.
OK,播放成功。有点卡。
本文档详细介绍了如何在iOS环境中使用Xcode 4.6.2编译FFmpeg的过程,包括环境搭建、代码下载及配置等关键步骤,并提供了一个实际的示例项目。
410

被折叠的 条评论
为什么被折叠?



