关于ios中编译ffmpeg0.9.2库 推荐
2012-05-14 04:46
525 查看
很多朋友在问如何在ios中编译ffmpeg库,虽说网上的教程很多,但是大部分都说按其操作,最后编译总是不成功,正好我最近的项目要用到ffmpeg,所以就再次编译了,同时在这里记下,方便需要参考的朋友。
先说一下本次编译的环境:
mac os x 10.7.4
xcode4.2.1
ios5.0
ffmpeg0.9.2(最新的为0.10.3,一般不喜欢用最新的,原因不说了,所以这里选择次新的,^_^,有兴趣的朋友可以自己去测试最新的版本)
下面直接上步骤:
1:https://github.com/yuvi/gas-preprocessor下载gas-preprocessor.pl文件并将其放置到/usr/sbin路径下,然后对其赋予权限,如下所示:
2:到ffmpeg的官网http://ffmpeg.org/download.html下载所需要版本代码,这里选择ffmpeg0.9.2,解压之后会得到一个ffmpeg-0.9.2的文件夹。
3:从终端进入到加压出来的ffmpeg-0.9.2文件夹,并执行make clean命令,清除上次生成的库文件。
4:编译配置(分为模拟器和真机两个版本)
4.1:模拟器版本编译配置,在终端执行如下命令:
4.2:真机版本编译配置,在终端执行如下命令:
注意:需要将其中的sdk路径更换为自己环境所对应的sdk路径,注意命令中的空格。
配置成功之后将出现如下画面,如果没有成功,则仔细检查命令是否正确:
5:编译,最简单了,在终端执行make命令即可,如果出现以下画面,则表示编译成功:
上面的代码本人亲测,能编译通过,如果不能编译成功的请仔细检查每一步是否操作正确,同时在文末我提供了一个我编译的真机版本的控制台输出信息,大家可以核对。
另外,很多朋友都在使用iFrameExtractor项目(git clone git://github.com/lajos/iFrameExtractor.git)作为测试,如果你选择的ffmpeg版本在0.8.5及其以上,那么需要将VideoFrameExtractor.m中72行的codec_type值改为AVMEDIA_TYPE_VIDEO,如下所示:
当然了,你也可以按照iFrameExtractor项目项目中的build_armv6\build_armv7\build_i386\build_universal制作成一个编译脚本,方便后期的编译,如有需要,我后期有时间了,将整理上传。
最后,本次的项目主要是想用ffmpeg进行编解码,使用opengl es进行图像视频渲染,openal进行音频播放,即这三个开源工程的整合,如果大家有很么好的建议,也欢迎交流 @杨丰盛。
附件:http://down.51cto.com/data/2360567
先说一下本次编译的环境:
mac os x 10.7.4
xcode4.2.1
ios5.0
ffmpeg0.9.2(最新的为0.10.3,一般不喜欢用最新的,原因不说了,所以这里选择次新的,^_^,有兴趣的朋友可以自己去测试最新的版本)
下面直接上步骤:
1:https://github.com/yuvi/gas-preprocessor下载gas-preprocessor.pl文件并将其放置到/usr/sbin路径下,然后对其赋予权限,如下所示:
cd /usr/sbin chmod 777 gas-preprocessor.pl
2:到ffmpeg的官网http://ffmpeg.org/download.html下载所需要版本代码,这里选择ffmpeg0.9.2,解压之后会得到一个ffmpeg-0.9.2的文件夹。
3:从终端进入到加压出来的ffmpeg-0.9.2文件夹,并执行make clean命令,清除上次生成的库文件。
4:编译配置(分为模拟器和真机两个版本)
4.1:模拟器版本编译配置,在终端执行如下命令:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-avfilter --disable-debug --disable-encoders --enable-cross-compile --disable-decoders --disable-armv5te --enable-decoder=h264 --enable-pic --cc=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' --extra-ldflags=-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system --sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk --target-os=darwin --arch=i386 --cpu=i386 --extra-cflags='-arch i386' --extra-ldflags='-arch i386' --disable-asm
4.2:真机版本编译配置,在终端执行如下命令:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-avfilter --disable-debug --disable-decoders --enable-cross-compile --disable-encoders --disable-armv5te --enable-decoder=h264 --enable-pic --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --target-os=darwin --arch=arm --cpu=cortex-a8 --extra-cflags='-arch armv7' --disable-asm
注意:需要将其中的sdk路径更换为自己环境所对应的sdk路径,注意命令中的空格。
配置成功之后将出现如下画面,如果没有成功,则仔细检查命令是否正确:
Enabled filters: abuffer earwax pad abuffersink fade pan aconvert fieldorder pixdesctest aevalsrc fifo rgbtestsrc aformat format scale amovie gradfun select anull hflip setdar anullsink life setpts anullsrc lut setsar aresample lutrgb settb ashowinfo lutyuv showinfo buffer mandelbrot slicify buffersink movie split cellauto negate testsrc color noformat transpose copy null unsharp crop nullsink vflip deshake nullsrc volume drawbox overlay Enabled bsfs: aac_adtstoasc mjpeg2jpeg noise chomp mjpega_dump_header remove_extradata dump_extradata mov2textsub text2movsub h264_mp4toannexb mp3_header_compress imx_dump_header mp3_header_decompress Enabled indevs: Enabled outdevs: License: LGPL version 2.1 or later Creating config.mak and config.h... WARNING: pkg-config not found, library detection may fail. WARNING: Compiler does not indicate floating-point ABI, guessing soft. Yarin-YangmatoiMac:ffmpeg-0.9.2 yarin$
5:编译,最简单了,在终端执行make命令即可,如果出现以下画面,则表示编译成功:
libavutil/opt.c: In function ‘av_opt_ptr’: libavutil/opt.c:811: warning: initialization discards qualifiers from pointer target type CC libavutil/parseutils.o CC libavutil/pixdesc.o CC libavutil/random_seed.o CC libavutil/rational.o CC libavutil/rc4.o CC libavutil/samplefmt.o CC libavutil/sha.o CC libavutil/tree.o CC libavutil/utils.o AR libavutil/libavutil.a CC ffprobe.o ffprobe.c: In function ‘probe_file’: ffprobe.c:1163: warning: ‘av_close_input_file’ is deprecated (declared at libavformat/avformat.h:1652) CC cmdutils.o LD ffprobe_g CP ffprobe STRIP ffprobe Yarin-YangmatoiMac:ffmpeg-0.9.2 yarin$
上面的代码本人亲测,能编译通过,如果不能编译成功的请仔细检查每一步是否操作正确,同时在文末我提供了一个我编译的真机版本的控制台输出信息,大家可以核对。
另外,很多朋友都在使用iFrameExtractor项目(git clone git://github.com/lajos/iFrameExtractor.git)作为测试,如果你选择的ffmpeg版本在0.8.5及其以上,那么需要将VideoFrameExtractor.m中72行的codec_type值改为AVMEDIA_TYPE_VIDEO,如下所示:
// Find the first video stream videoStream=-1; for(int i=0; i<pFormatCtx->nb_streams; i++) if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) { videoStream=i; break; }
当然了,你也可以按照iFrameExtractor项目项目中的build_armv6\build_armv7\build_i386\build_universal制作成一个编译脚本,方便后期的编译,如有需要,我后期有时间了,将整理上传。
最后,本次的项目主要是想用ffmpeg进行编解码,使用opengl es进行图像视频渲染,openal进行音频播放,即这三个开源工程的整合,如果大家有很么好的建议,也欢迎交流 @杨丰盛。
附件:http://down.51cto.com/data/2360567
相关文章推荐
- 关于ios中编译ffmpeg0.9.2库
- 关于ios中编译ffmpeg0.9.2库
- 关于ios中编译ffmpeg0.9.2库
- 关于iOS上使用ffmpeg的编译配置
- 关于使用Android NDK编译ffmpeg 推荐
- 关于ios中编译ffmpeg0.9.2库
- 关于ios中编译ffmpeg0.9.2库
- 关于ios FFmpeg 32位和64位 裁剪编译优化(安卓解码720P没问题)记录
- 关于使用Android&nbsp;NDK编译ffmpeg
- 编译针对iOS平台的ffmpeg
- iOS FFMpeg的编译和使用
- iOS: FFmpeg编译和使用问题总结
- ios 配置编译好的ffmpeg解码库报错
- 关于iOS使用FFmpeg直播rtsp流的一点记录
- iOS: FFMpeg编译和使用问题总结
- FFmpeg在iOS上完美编译
- IOS旗下基于FFmpeg开发的开源流媒体播放器汇总推荐
- 编译最新ffmpeg2.0.1到iOS设备
- iOS编译libx264+libfdk-aac+FFmpeg
- 关于ffmpeg编译以及运行的问题