您的位置:首页 > 移动开发 > IOS开发

iOS编译ffmpeg1.2.1,使用kxmovie播放视频文件

2013-10-24 21:13 507 查看
今天完成了,iOS上面播放视频的功能,特写此日记,以便以后用到

我的环境是xcode5.0.1+iOS6.0SDK(喜欢的话可以直接使用7.0的SDK,不过为了兼容,我选择了6.0的),ffmpeg的版本是1.2.1,系统版本是10.8.5


1、先来看编译模拟器的ffmpeg库:

使用脚本compile.sh,内容如下:

SRCDIR=`pwd`
SDKVERSION="6.0"

make clean

CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \
./configure \
--as='/usr/local/bin/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/iPhoneSimulator5.1.sdk \
--target-os=darwin \
--arch=i386 \
--cpu=i386 \
--extra-cflags='-arch i386' \
--extra-ldflags='-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk' \
--prefix=compiled/i386 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug

make && make install




然后执行sh compile.sh,一段时间后,就可以在当前目录的compiled文件夹下面,找到i386的子目录,里面的lib自文件夹中存放的就是模拟器版本的ffmpeg解码库



下面打开kxmovie工程,把刚才生成的lib文件夹,拷贝到工程目录中:



用xcode打开这个工程,把刚才加入的lib文件夹导入到当前工程中:



找到MainViewController.m文件,因为我在内网部署了对应的http和rtsp服务器,rtmp的也部署了,但是这里似乎没能访问(所以rtmp部分还是使用原来的那些链接)。

command+R打开模拟器,看看效果(使用6.0的一个模拟器,因为我的手机是6.1.4的系统):








2、下面是真机库的编译:

使用compile-armv7s.sh,内容如下:

./configure --prefix=armv7s --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk" --target-os=darwin --cc="/Applications/XCode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=6.0" --extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=6.0" --arch=arm --cpu=cortex-a9 --enable-pic


同样的因为我这里,真机的iOS版本是6.1.4的,所以这里选择min=6.0,表示支持的系统最低是6.0的

运行上面的sh compile-armv7s.sh,在使用make,make install。

编译之后在当前文件夹下出现armv7s的文件夹,里面有和上面我们需要的同一样的lib文件夹:



同样和上面,拷贝到工程中,然后用kxmovie打开,在引入到工程中。

选择我们的真机,然后commond+R,执行一下App,可以在手机上边看到效果:





好了 到此为止,想要什么效果,我们只需要按照kxmovie里面的例子进行修改即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: