Use ffmepg on iOS

Source: Internet
Author: User

Note: I 've found a lot of articles on the Internet to see how to port FFMPEG to iOS. There are always a lot of problems with the results, and the help of FFmpeg is just that. It's really a headache. It took two weeks, finally, the FFmpeg is given. Therefore, I feel the confusion and helplessness of new users. I am determined to write down my experience so that more people can avoid detours. I would like to express my great thanks to the "I don't know who I am" and the "Wind vs the world" netizens who gave me selfless help.

If you need to repost the content, please keep the current website and at least respect me for the effort to write it down and share it.

 

The procedure is as follows:

1 from the supervisor, and add execution permissions to it, here you can directly give the highest permission chmod777 gas-preprocessor.pl

For example:

2 download the latest code http://ffmpeg.org/download.html from FFMPEG's official website, such as the latest 0.10

Choose one download here

3. Download The iframeextractor project from gitclone git: // github.com/lajos/iframeextractor.git. It may not be available for download because Chinese companies generally impose restrictions and can search for it online. Many projects have little difference, FFmpeg is not affected.

Then, place the downloaded FFMPEG in the folder of the iframeextractor project. The structure is as follows:

4 open terminal, CD to the ffmpeg-0.10 folder, execute makeclean, clear the previously generated library file.

5. If you want to generate a library file that can be used by the simulator.

Environment: Mac lion 10.7.2, xcode: 4.2.1,

Simulator (during runtime, I will test it with a simulator of 5.0 temporarily)

SDK:/developer/platforms/iphonesimulator. Platform/developer/sdks/iphonesimulator5.0.sdk

SDK:/developer/platforms/iphonesimulator. Platform/developer/sdks/iphonesimulator4.3.sdk

Run the following command:

. /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/iphonesimulator4.3.sdk/usr/lib/System -- sysroot =/developer/platforms/iphonesimulator. platform/developer/sdks/iphonesimulator4.3.sdk -- target-OS = Darwin
-- Arch = i386 -- CPU = i386 -- extra-cflags = '-arch i386' -- extra-ldflags = '-arch i386' -- disable-ASM

After the command is executed, no error is reported, similar:

6. Run the make command. (Sometimes there will be errors. It is recommended to try it twice. If there is no error, it should be similar)

At this time, you can go to the ffmepg folder to view the libavutil/libavutil. A, libswscale/libswscale. A, libavcodec/libavcodec. A, libavformat/libavformat. A files should have been generated.

7. Open the downloaded iframeextracto project,

Set the header search paths in build setting in the project to the./ffmpeg-0.10 for the current location, such:

Set the header search paths of build setting in target to the./ffmpeg-0.10 of the current location. For example:

Here, we will not set the libaray search paths under the target for the time being, and delete all the paths. (Because after these library files are added, the libarary search paths will be automatically filled in)

8. delete some library file references before the project (including the library files under the project and library file references on the right of the target)

 

9. Click "linkbinary with libaries" in build phases of target to find and add these library files. After adding these files, you can go to the "library search paths" under the build settings under the target to automatically fill in the paths of these library files, and ensure that the library libbz2.1.0.dylib has been added.

Then compile and run. iframeextractor should be running on the simulator.

 

Compile FFMPEG on a real machine

5 (different from step 1 above)

Environment: Mac lion 10.7.2, xcode: 4.2.1,

In xcode, The Real-machine SDK version is:/developer/platforms/iphoneos. Platform/developer/sdks/iphoneos5.0.sdk.

Real machine, itouch 4 (SDK 5.0.1 installed)

Make clean to clear existing library files.

Run

. /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'

After the execution is completed, follow these steps: (if there is no error)

6. An error is reported when you execute make. Error: Invalid operand in inline ASM: 'adds $1, $ {2: R}, $ {2: Q}, and LSR #31 are incorrect as follows:

I checked it online and said that if you do not need the support for ASM in your project, you can disable it. /-- disable-ASM added at the end of configure is changed to the following:

. /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

The configuration is correct, and then make is compiled successfully, for example:

The newly generated library file is displayed in the corresponding folder.

Then the subsequent steps are the same as those on the simulator and finally run on your mobile phone.

The preceding real machine method applies to iOS 4 and ios5.

The following command can be used on the ios6 system. It has been tested. The iPhone 4 and (iOS 6) are installed normally.

. /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 =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC
-- As = 'Gas-Preprocessor/gas-preprocessor.pl/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC '-- extra-ldflags ='-arch armv7-isysroot/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.0.sdk'
-- Sysroot =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.0.sdk -- target-OS = Darwin -- arch = arm -- CPU = cortex-a8 -- extra-cflags = '-arch armv7' -- disable-ASM

Related Article

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.