NOTE: Refer to the Internet for personal adjustment and testing.
Test video address: http://livecdn.cdbs.com.cn/fmvideo.flv
(The image upload function of mbd and cnblogs is unavailable, and a picture is sent to Sina Weibo .)
I. Prepare the debugging environment 1. operating System: Mac OS 10.7.42. xcode version: xcode 4.4.1 3. make sure that the command line tools of xcode is installed, and the command line tools are located in the xcode-> perference-> downloads directory 4. ensure that git works properly, install xcode, git should be able to work normally in terminal, if the work is not normal, you can download gitfor Mac: http://code.google.com/p/git-osx-installer/ at the following link
Ii. Download Code 1. Download FFMPEG source code
Git clone git: // source.ffmpeg.org/ffmpeg.git FFMPEG
Reference: http://ffmpeg.org/download.html
2. Download FFMPEG-iPhone-build
Git clone https://github.com/gabriel/ffmpeg-iphone-build.git
Reference: https://github.com/gabriel/ffmpeg-iphone-build
3. Compile 1. Copy FFMPEG-iPhone-build/gas-preprocessor.pl to the/usr/sbin directory 2. Compile FFMPEG for iOS i386
(1) copy the new downloaded ffmpeg to the ffmpeg-iPhone-build directory, renamed as ffmpeg-i386
(2) Use textedit to open the comments of the build-i386 file # svnco-r22403 SVN: // svn.ffmpeg.org/ffmpeg/trunk $ ffmpeg_dir this line
(3) add -- disable-ASM -- enable-Cross-compile in configure_options.
(4) modify the row where./configure is located:
./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" --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk --extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=i386 --cpu=i386 --extra-cflags='-arch i386' --extra-ldflags='-arch i386'
(4) Run./build-i386 in Terminal
3. Compile FFMPEG for iOS armv7
(1) copy the new downloaded ffmpeg to the ffmpeg-iPhone-build directory, renamed as ffmpeg-armv7
(2) Use textedit to open the comments of the build-armv7 file # svnco-r22403 SVN: // svn.ffmpeg.org/ffmpeg/trunk $ ffmpeg_dir this line
(3) add -- disable-ASM -- enable-Cross-compile in configure_options.
(4) change./configure:
./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" --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=armv7 --cpu=armv7 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7'
(5) Run./build-armv7 in Terminal
4. Compile FFMPEG for iOS armv6
(1) copy the new downloaded ffmpeg to the ffmpeg-iPhone-build directory, renamed as ffmpeg-armv6
(2) Use textedit to open the comments of the build-armv6 file # svnco-r22403 SVN: // svn.ffmpeg.org/ffmpeg/trunk $ ffmpeg_dir this line
(3) add -- disable-ASM -- enable-Cross-compile in configure_options
(4)./configure:
./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" --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=armv6 --cpu=armv6 --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6'
(5) Run./build-armv6 in Terminal
5. Merge armv6 armv7 i386 to create a fat static library
(1) Create the build-universal file. The file content is
#!/bin/tcsh -f mkdir universalmkdir libmkdir armv6mkdir armv7mkdir i386 mv ffmpeg-armv6/libavcodec/libavcodec.a armv6/mv ffmpeg-armv6/libavdevice/libavdevice.a armv6/mv ffmpeg-armv6/libavformat/libavformat.a armv6/mv ffmpeg-armv6/libavutil/libavutil.a armv6/mv ffmpeg-armv6/libswscale/libswscale.a armv6/ mv ffmpeg-armv7/libavcodec/libavcodec.a armv7/mv ffmpeg-armv7/libavdevice/libavdevice.a armv7/mv ffmpeg-armv7/libavformat/libavformat.a armv7/mv ffmpeg-armv7/libavutil/libavutil.a armv7/mv ffmpeg-armv7/libswscale/libswscale.a armv7/ mv ffmpeg-i386/libavcodec/libavcodec.a i386/mv ffmpeg-i386/libavdevice/libavdevice.a i386/mv ffmpeg-i386/libavformat/libavformat.a i386/mv ffmpeg-i386/libavutil/libavutil.a i386/mv ffmpeg-i386/libswscale/libswscale.a i386/ rm universal/*.alipo -create -arch armv6 armv6/libavcodec.a -arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -output universal/libavcodec.alipo -create -arch armv6 armv6/libavdevice.a -arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -output universal/libavdevice.alipo -create -arch armv6 armv6/libavformat.a -arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -output universal/libavformat.alipo -create -arch armv6 armv6/libavutil.a -arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -output universal/libavutil.alipo -create -arch armv6 armv6/libswscale.a -arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -output universal/libswscale.arm lib/*.acp universal/*.a lib/
(2) run the build-universal file./build-Universal
At this point, all we need is in the LIB/directory.
Iv. debug iframeextractor demo
For more information, see the open-source example iframeextractor (GIT clone git: // github.com/lajos/iframeextractor.git ).ReplaceCreate a new lib directory under the FFMPEG directory for the FFMPEG source code folder compiled for you, and copy the static library compiled in the LIB/directory in the previous step. Open the project and click compile and run. ####/iframeextractor/FFMPEG/libavutil/common appears. h: 38: 10: 'libavutil/avconfig. h'file not found. You can create avconfig. h file, the content is as follows (can also be from FFMPEG-iPhone-build/ffmpeg-i386/libavutil/avconfig. h ):
/* Generated by ffconf */#ifndef AVUTIL_AVCONFIG_H#define AVUTIL_AVCONFIG_H#define AV_HAVE_BIGENDIAN 0#define AV_HAVE_FAST_UNALIGNED 0#define AV_HAVE_INCOMPATIBLE_FORK_ABI 0#endif /* AVUTIL_AVCONFIG_H */
Continue running in xcode with the following error: Use of undeclared identifier 'codec _ type_video'
Solution: Change codec_type_video in iframeextractor to avmedia_type_video. (Note that you need to modify the version <= ffmpeg0.8.5 Library)
Some errors have occurred while continuing to run,
Undefined symbols for architecture i386: "_BZ2_bzDecompress", referenced from: _matroska_decode_buffer in libavformat.a(matroskadec.o) "_BZ2_bzDecompressEnd", referenced from: _matroska_decode_buffer in libavformat.a(matroskadec.o) "_BZ2_bzDecompressInit", referenced from: _matroska_decode_buffer in libavformat.a(matroskadec.o) "_av_open_input_file", referenced from: -[VideoFrameExtractor initWithVideo:] in VideoFrameExtractor.old: symbol(s) not found for architecture i386clang: error: linker command failed with exit code 1 (use -v to see invocation)
The solution is as follows:
Add the libbz2.1.0.dylib Library to the project.
Continue execution. If the following error occurs:
Undefined symbols for architecture i386: "_av_open_input_file", referenced from: -[VideoFrameExtractor initWithVideo:] in VideoFrameExtractor.o
Set
Av_open_input_file (& pformatctx, [moviepath cstringusingencoding: nsasciistringencoding], null, 0, null )! = 0
Avformat_open_input (& pformatctx, [moviepath cstringusingencoding: nsasciistringencoding], null, null )! = 0
At this time, the operation is successful. Several network addresses are added to the FLV test to decode the video, but there are no sound and sometimes interruptions. There are still a few issues that will be warned if the video is not replaced (I am not very familiar with it yet, ).