Compile the ffmpeg0.9.2 library in ios

Source: Internet
Author: User

Many of my friends are asking how to compile the ffmpeg library in ios. Although there are many tutorials on the Internet, most of them say that the compilation is always unsuccessful, I used ffmpeg in my recent project, so I compiled it again and wrote it down here for your reference.
Let's talk about the compiling environment:
Mac OS x 10.7.4
Xcode4.2.1
Ios5.0
Ffmpeg0.9.2)
The preceding steps are as follows:
1: bytes:
1. cd/usr/sbin
2. chmod 777 gas-preprocessor.pl
2: Go to ffmpeg's official website.
3: Enter the pressurized ffmpeg-0.9.2 folder from the terminal, and execute the make clean command to clear the last generated library file.
4: Compile the configuration (it can be divided into two versions: simulator and real machine)
4.1: Compile and configure the Simulator version. Run the following command on the terminal:
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: Compile and configure the real machine version. Run the following command on the terminal:
1 .. /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
Note: Replace the sdk path with the sdk path corresponding to your environment. Note the space in the command.
After the configuration is successful, the following screen appears. If the configuration fails, check whether the command is correct:
1. Enabled filters:
2. abuffer earwax pad
3. abuffersink fade pan
4. aconvert fieldorder pixdesctest
5. aevalsrc fifo rgbtestsrc
6. aformat format scale
7. amovie gradfun select
8. anull hflip setdar
9. anullsink life setpts
10. anullsrc lut setsar
11. aresample lutrgb settb
12. ashowinfo lutyuv showinfo
13. buffer mandelbrot slicify
14. buffersink movie split
15. cellauto negate testsrc
16. color noformat transpose
17. copy null unsharp
18. crop nullsink vflip
19. deshake nullsrc volume
20. drawbox overlay
21.
22. Enabled bsfs:
23. aac_adtstoasc m3162jpeg noise
24. chomp mjpega_dump_header remove_extradata
25. dump_extradata mov2textsub text2movsub
26. h1__mp4to1_ B mp3_header_compress
27. imx_dump_header mp3_header_decompress
28.
29. Enabled indevs:
30.
31. Enabled outdevs:
32.
33. License: LGPL version 2.1 or later
34. Creating config. mak and config. h...
35.
36. WARNING: pkg-config not found, library detection may fail.
37. WARNING: Compiler does not indicate floating-point ABI, guessing soft.
38. Yarin-YangmatoiMac: ffmpeg-0.9.2 yarin $
5: Compile. It is the simplest. Execute the make command on the terminal. If the following screen appears, the compilation is successful:
1. libavutil/opt. c: In function 'av _ opt_ptr ':
2. libavutil/opt. c: 811: warning: initialization discards qualifiers from pointer target type
3. CC libavutil/parseutils. o
4. CC libavutil/pixdesc. o
5. CC libavutil/random_seed.o
6. CC libavutil/rational. o
7. CC libavutil/rc4.o
8. CC libavutil/samplefmt. o
9. CC libavutil/sha. o
10. CC libavutil/tree. o
11. CC libavutil/utils. o
12. AR libavutil/libavutil.
13. CC ffprobe. o
14. ffprobe. c: In function 'probe _ file ':
15. ffprobe. c: 1163: warning: 'av _ close_input_file 'is deprecated (declared at libavformat/avformat. h: 1652)
16. CC cmdutils. o
17. LD ffprobe_g
18. CP ffprobe
19. STRIP ffprobe
20. Yarin-YangmatoiMac: ffmpeg-0.9.2 yarin $
The above code is tested by myself and can be compiled successfully. If compilation fails, Please carefully check whether each step is correct, at the end of the article, I provide the console output information of the compiled real machine version. You can check the information.
In addition, many of my friends are using the iFrameExtractor Project (git clone git: // github.com/lajos/iFrameExtractor.git) as a test. If you select the ffmpeg version 0.8.5 or later, you need to set VideoFrameExtractor. change the codec_type value of row 72 in m to AVMEDIA_TYPE_VIDEO, as shown below:
1. // Find the first video stream
2. videoStream =-1;
3. for (int I = 0; I <pFormatCtx-> nb_streams; I ++)
4. if (pFormatCtx-> streams [I]-> codec-> codec_type = AVMEDIA_TYPE_VIDEO)
5 .{
6. videoStream = I;
7. break;
8 .}
Of course, you can also create a compilation script based on build_armv6 \ build_armv7 \ build_i386 \ build_universal in the iFrameExtractor project to facilitate later compilation. If necessary, I will have time later, upload the files.
Finally, this project mainly aims to use ffmpeg for codec, opengl es for image and video rendering, and openal for audio playback, that is, the integration of the three open source projects, if you have any good suggestions, please feel free to contact @ Yang rich.

 

 

From "yarin's blog™"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.