参考文章:
http://stackoverflow.com/questions/8323672/ffmpeg-for-ios5
中央电视3台:rtsp地址:rtsp://114.255.201.246/cctv3_256_h264.sdp
开发环境:
Mac OS X 10.6.8
一、下载ffmpeg4ios、gas-preprocessor、yasm
1、下载ffmpeg4ios:https://github.com/ciphor/ffmpeg4ios
$ git clone http://github.com/ciphor/ffmpeg4ios $ cd ffmpeg4ios $ chmod -R a+x ./
2、下载gas-preprocessor:https://github.com/yuvi/gas-preprocessor
$ git clone https://github.com/yuvi/gas-preprocessor
复制到/usr/local/bin目录下
$ cp gas-preprocessor/gas-preprocessor.pl /usr/local/bin/
3、yasm下载(非必须):
用mac下的MacPorts下载yasm,前提是系统已经安装了MacProts
Macports安装方法:http://www.ccvita.com/434.html
通过Macports下载并且安装yasm:
sudo port install yasm
4、编译
在ffmpeg4ios目录下执行build_armv7
$ ./build_armv7
build_armv7脚本内容:
/Developer_Xcode_4.2_ios_sdk_5.0.1可以根据机器的安装路径不同更改目录路径
if (! -d armv7) mkdir armv7 if (! -d lib) mkdir lib rm armv7/*.a make clean ./configure --disable-network --disable-mpegaudio-hp --disable-lpc --disable-vaapi --disable-vdpau --disable-hwaccels --disable-mmx --disable-mmx2 --disable-sse --disable-ssse3 --disable-avx --disable-amd3dnow --disable-amd3dnowext --disable-vis --disable-mmi --disable-doc --disable-yasm --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-rdft --disable-dxva2 --disable-encoders --disable-decoders --enable-decoder=h264 --disable-bsfs --disable-protocols --disable-indevs --disable-outdevs --disable-devices --disable-filters --disable-demuxers --enable-demuxer=h264 --disable-muxers --disable-parsers --enable-parser=h264 --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer_Xcode_4.2_ios_sdk_5.0.1/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer_Xcode_4.2_ios_sdk_5.0.1/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Developer_Xcode_4.2_ios_sdk_5.0.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer_Xcode_4.2_ios_sdk_5.0.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --enable-pic perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h make -j4 mv libavcodec/libavcodec.a armv7/ mv libavdevice/libavdevice.a armv7/ mv libavformat/libavformat.a armv7/ mv libavutil/libavutil.a armv7/ mv libswscale/libswscale.a armv7/ rm lib/*.a cp armv7/*.a lib/
编译输出如下:
install prefix /usr/local source path /Users/apple/desktop/ffmpeg4ios C compiler /Developer_Xcode_4.2_ios_sdk_5.0.1/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc ARCH arm (cortex-a8) big-endian no runtime cpu detection no ARMv5TE enabled yes ARMv6 enabled yes ARMv6T2 enabled yes ARM VFP enabled yes IWMMXT enabled no NEON enabled yes debug symbols yes strip symbols yes optimizations yes static yes shared no postprocessing support no new filter support yes network support no threading support pthreads SDL support no Sun medialib support no AVISynth enabled no libcelt enabled no frei0r enabled no libdc1394 support no libdirac enabled no libfaac enabled no libgsm enabled no libmp3lame enabled no libnut enabled no libopencore-amrnb support no libopencore-amrwb support no libopencv support no libopenjpeg enabled no librtmp enabled no libschroedinger enabled no libspeex enabled no libtheora enabled no libva enabled no libvo-aacenc support no libvo-amrwbenc support no libvorbis enabled no libvpx enabled no libx264 enabled no libxavs enabled no libxvid enabled no zlib enabled no bzlib enabled no Enabled decoders: h264 Enabled encoders: Enabled hwaccels: Enabled parsers: h264 Enabled demuxers: h264 Enabled muxers: Enabled protocols: Enabled filters: Enabled bsfs: Enabled indevs: Enabled outdevs: License: LGPL version 2.1 or later Creating config.mak and config.h... WARNING: Compiler does not indicate floating-point ABI, guessing soft. CC libavdevice/alldevices.o CC libavdevice/avdevice.o CC libavfilter/allfilters.o CC libavfilter/avfilter.o CC libavfilter/avfiltergraph.o libavfilter/avfilter.c:219: warning: ‘ff_get_ref_perms_string’ defined but not used CC libavfilter/defaults.o CC libavfilter/drawutils.o CC libavfilter/formats.o CC libavfilter/graphparser.o CC libavformat/allformats.o CC libavformat/avio.o CC libavformat/aviobuf.o libavformat/avio.c: In function ‘avio_enum_protocols’: libavformat/avio.c:60: warning: initialization from incompatible pointer type libavformat/avio.c: In function ‘ffurl_write’: libavformat/avio.c:310: warning: passing argument 2 of ‘retry_transfer_wrapper’ discards qualifiers from pointer target type CC libavformat/cutils.o CC libavformat/h264dec.o libavformat/aviobuf.c: In function ‘ffio_init_context’: libavformat/aviobuf.c:65: warning: ‘is_streamed’ is deprecated (declared at libavformat/avio.h:68) libavformat/aviobuf.c: In function ‘ffio_fdopen’: libavformat/aviobuf.c:862: warning: ‘is_streamed’ is deprecated (declared at libavformat/avio.h:68) CC libavformat/id3v1.o CC libavformat/id3v2.o CC libavformat/metadata.o libavformat/metadata.c: In function ‘av_metadata_set2’: libavformat/metadata.c:72: warning: assignment discards qualifiers from pointer target type libavformat/metadata.c:76: warning: assignment discards qualifiers from pointer target type CC libavformat/options.o CC libavformat/os_support.o CC libavformat/rawdec.o CC libavformat/sdp.o CC libavformat/seek.o CC libavformat/utils.o CC libavcodec/allcodecs.o AS libavcodec/arm/dsputil_arm.o libavformat/utils.c: In function ‘av_seek_frame_generic’: libavformat/utils.c:1683: warning: ‘read_seek’ is deprecated (declared at libavformat/avformat.h:375) libavformat/utils.c:1684: warning: ‘read_seek’ is deprecated (declared at libavformat/avformat.h:375) libavformat/utils.c: In function ‘av_seek_frame’: libavformat/utils.c:1716: warning: ‘read_seek’ is deprecated (declared at libavformat/avformat.h:375) libavformat/utils.c:1717: warning: ‘read_seek’ is deprecated (declared at libavformat/avformat.h:375) libavformat/utils.c: In function ‘avformat_seek_file’: libavformat/utils.c:1746: warning: ‘read_seek’ is deprecated (declared at libavformat/avformat.h:375) libavformat/utils.c: In function ‘av_write_frame’: libavformat/utils.c:2949: warning: ‘url_ferror’ is deprecated (declared at libavformat/avio.h:302) libavformat/utils.c: In function ‘av_interleaved_write_frame’: libavformat/utils.c:3076: warning: ‘url_ferror’ is deprecated (declared at libavformat/avio.h:302) libavformat/utils.c:3077: warning: ‘url_ferror’ is deprecated (declared at libavformat/avio.h:302) libavformat/utils.c: In function ‘av_write_trailer’: libavformat/utils.c:3099: warning: ‘url_ferror’ is deprecated (declared at libavformat/avio.h:302) libavformat/utils.c:3107: warning: ‘url_ferror’ is deprecated (declared at libavformat/avio.h:302) AS libavcodec/arm/dsputil_armv6.o CC libavcodec/arm/dsputil_init_arm.o CC libavcodec/arm/dsputil_init_armv5te.o CC libavcodec/arm/dsputil_init_armv6.o CC libavcodec/arm/dsputil_init_neon.o CC libavcodec/arm/dsputil_init_vfp.o AS libavcodec/arm/dsputil_neon.o AS libavcodec/arm/dsputil_vfp.o CC libavcodec/arm/fft_fixed_init_arm.o CC libavcodec/arm/fft_init_arm.o CC libavcodec/arm/fmtconvert_init_arm.o AS libavcodec/arm/fmtconvert_neon.o AS libavcodec/arm/fmtconvert_vfp.o CC libavcodec/arm/h264dsp_init_arm.o AS libavcodec/arm/h264dsp_neon.o AS libavcodec/arm/h264idct_neon.o CC libavcodec/arm/h264pred_init_arm.o AS libavcodec/arm/h264pred_neon.o AS libavcodec/arm/int_neon.o AS libavcodec/arm/jrevdct_arm.o CC libavcodec/arm/mpegvideo_arm.o CC libavcodec/arm/mpegvideo_armv5te.o AS libavcodec/arm/mpegvideo_armv5te_s.o AS libavcodec/arm/mpegvideo_neon.o AS libavcodec/arm/simple_idct_arm.o AS libavcodec/arm/simple_idct_armv5te.o AS libavcodec/arm/simple_idct_armv6.o AS libavcodec/arm/simple_idct_neon.o CC libavcodec/audioconvert.o CC libavcodec/avpacket.o CC libavcodec/bitstream.o libavcodec/avpacket.c: In function ‘av_dup_packet’: libavcodec/avpacket.c:125: warning: ‘av_destruct_packet_nofree’ is deprecated (declared at libavcodec/avpacket.c:27) CC libavcodec/bitstream_filter.o CC libavcodec/cabac.o libavcodec/bitstream_filter.c: In function ‘av_bitstream_filter_filter’: libavcodec/bitstream_filter.c:62: warning: cast discards qualifiers from pointer target type CC libavcodec/dsputil.o CC libavcodec/error_resilience.o CC libavcodec/faanidct.o CC libavcodec/fmtconvert.o CC libavcodec/golomb.o CC libavcodec/h264.o CC libavcodec/h264_cabac.o libavcodec/h264.c: In function ‘fill_filter_caches’: libavcodec/h264.c:2442: warning: initialization from incompatible pointer type libavcodec/h264.c:2519: warning: initialization from incompatible pointer type libavcodec/h264.c:2534: warning: initialization from incompatible pointer type CC libavcodec/h264_cavlc.o CC libavcodec/h264_direct.o libavcodec/h264_direct.c: In function ‘pred_spatial_direct_motion’: libavcodec/h264_direct.c:287: warning: assignment from incompatible pointer type libavcodec/h264_direct.c:288: warning: assignment from incompatible pointer type libavcodec/h264_direct.c: In function ‘pred_temp_direct_motion’: libavcodec/h264_direct.c:474: warning: assignment from incompatible pointer type libavcodec/h264_direct.c:475: warning: assignment from incompatible pointer type CC libavcodec/h264_hl_motion.o CC libavcodec/h264_loopfilter.o CC libavcodec/h264_parser.o CC libavcodec/h264_ps.o CC libavcodec/h264_refs.o CC libavcodec/h264_sei.o CC libavcodec/h264dsp.o CC libavcodec/h264idct.o CC libavcodec/h264pred.o CC libavcodec/imgconvert.o libavcodec/imgconvert.c: In function ‘av_picture_copy’: libavcodec/imgconvert.c:671: warning: passing argument 3 of ‘av_image_copy’ from incompatible pointer type CC libavcodec/inverse.o CC libavcodec/jrevdct.o CC libavcodec/mpegvideo.o CC libavcodec/options.o libavcodec/options.c:317: warning: ‘antialias_algo’ is deprecated (declared at libavcodec/avcodec.h:2144) libavcodec/options.c: In function ‘avcodec_get_context_defaults3’: libavcodec/options.c:502: warning: assignment discards qualifiers from pointer target type CC libavcodec/parser.o libavcodec/parser.c: In function ‘av_parser_change’: libavcodec/parser.c:185: warning: cast discards qualifiers from pointer target type CC libavcodec/pthread.o CC libavcodec/raw.o CC libavcodec/resample.o CC libavcodec/resample2.o CC libavcodec/simple_idct.o CC libavcodec/utils.o libavcodec/utils.c: In function ‘avcodec_open’: libavcodec/utils.c:500: warning: assignment discards qualifiers from pointer target type libavcodec/utils.c: In function ‘avcodec_encode_audio’: libavcodec/utils.c:605: warning: passing argument 4 of ‘avctx->codec->encode’ discards qualifiers from pointer target type libavcodec/utils.c: In function ‘avcodec_encode_video’: libavcodec/utils.c:622: warning: passing argument 4 of ‘avctx->codec->encode’ discards qualifiers from pointer target type libavcodec/utils.c: In function ‘avcodec_encode_subtitle’: libavcodec/utils.c:641: warning: passing argument 4 of ‘avctx->codec->encode’ discards qualifiers from pointer target type libavcodec/utils.c:679:5: warning: "FF_API_VIDEO_OLD" is not defined CC libswscale/options.o CC libswscale/rgb2rgb.o CC libswscale/swscale.o In file included from libswscale/swscale.c:1258: libswscale/swscale_template.c: In function ‘hyscale_C’: libswscale/swscale_template.c:2409: warning: initialization from incompatible pointer type libswscale/swscale.c: In function ‘planarCopyWrapper’: libswscale/swscale.c:1750: warning: cast discards qualifiers from pointer target type libswscale/swscale.c: In function ‘sws_scale’: libswscale/swscale.c:1990: warning: passing argument 1 of ‘check_image_pointers’ from incompatible pointer type libswscale/swscale.c:1994: warning: passing argument 1 of ‘check_image_pointers’ discards qualifiers from pointer target type CC libswscale/utils.o CC libswscale/yuv2rgb.o CC libavutil/adler32.o CC libavutil/aes.o libavutil/aes.c: In function ‘av_aes_init’: libavutil/aes.c:160: warning: passing argument 1 of ‘init_multbl2’ from incompatible pointer type libavutil/aes.c:161: warning: passing argument 1 of ‘init_multbl2’ from incompatible pointer type CC libavutil/arm/cpu.o CC libavutil/audioconvert.o CC libavutil/avstring.o libavutil/avstring.c: In function ‘av_stristr’: libavutil/avstring.c:54: warning: return discards qualifiers from pointer target type libavutil/avstring.c:58: warning: return discards qualifiers from pointer target type CC libavutil/base64.o CC libavutil/cpu.o CC libavutil/crc.o CC libavutil/des.o CC libavutil/error.o CC libavutil/eval.o CC libavutil/fifo.o CC libavutil/file.o CC libavutil/imgutils.o CC libavutil/intfloat_readwrite.o CC libavutil/inverse.o CC libavutil/lfg.o CC libavutil/lls.o CC libavutil/log.o CC libavutil/lzo.o CC libavutil/mathematics.o CC libavutil/md5.o CC libavutil/mem.o CC libavutil/opt.o CC libavutil/parseutils.o libavutil/parseutils.c: In function ‘av_parse_video_size’: libavutil/parseutils.c:109: warning: assignment discards qualifiers from pointer target type libavutil/parseutils.c: In function ‘av_parse_time’: libavutil/parseutils.c:566: warning: cast discards qualifiers from pointer target type 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 libavdevice/libavdevice.a AR libavfilter/libavfilter.a AR libavformat/libavformat.a AR libswscale/libswscale.a /usr/bin/ranlib: file: libavformat/libavformat.a(os_support.o) has no symbols ranlib: file: libavformat/libavformat.a(os_support.o) has no symbols AR libavcodec/libavcodec.a AR libavutil/libavutil.a