About compiling the configuration using FFmpeg on iOS

Source: Internet
Author: User

The use of FFmpeg for audio and video development, first compile needs to compile FFmpeg source code into a static library, compilation is not a big problem, the key issue is the compilation of the various configurations of how to set the issue. Before the online search study, this article is good: Ios:ffmpeg compilation and use of the problem summary. Some articles give the entire command of the compilation, some to the script link, but there are some problems, because the FFmpeg version is updated and the iOS version is updated (I'm under ffmpeg2.3). Finally patchwork, finally compiled a successful one, the Compile command is:

(1)

./configure--prefix=. /i386--disable-ffmpeg--disable-ffplay--disable-ffprobe--disable-ffserver--enable-avresample-- Enable-cross-compile--sysroot= "/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/ Developer/sdks/iphonesimulator7.0.sdk "--target-os=darwin--cc="/applications/xcode.app/contents/developer/ Toolchains/xcodedefault.xctoolchain/usr/bin/clang "--extra-cflags="-arch i386-mfpu=neon-miphoneos-version-min= 7.0 "--extra-ldflags="-arch i386-isysroot/applications/xcode.app/contents/developer/platforms/ iphonesimulator.platform/developer/sdks/iphonesimulator7.0.sdk-miphoneos-version-min=7.0 "--arch=i386--cpu=i386 --enable-pic--disable-asm--enable-decoder=h264--enable-decoder=rv40
(2)
sudo make&&sudo make install

1, the complete process:

The first compile is to use the terminal to compile, open the terminal, after you download the extracted ffmpeg file directory, and then execute the above command. (1) Part is configuration, (2) Part of make execution will start compiling, will see quickly generate many cc beginning of the command; make install build static library, complete.

After the completion of the compilation, add to the project is OK, but a look at the size, I am, more than 200 m, no way to study the configuration items, see how to put unnecessary content does not mutate in. So I learned the meaning of the following commands.

2. Individual commands:

(1) First, each individual configuration item is separated by a space, this is a need to pay attention to the problem, afraid of shaking hands, put two commands together, such as

--disable-ffmpeg--disable-ffplay wrote--disable-ffmpeg--disable-ffplay.

then compile the time, the error said do not recognize--disable-ffmpeg--disable-ffplay, you think yourself these two commands wrong, in fact, the system is to think of it as a command.

(2)--prefix= is followed by a successful compilation after the static inventory put the path, you can create a new folder, dragged in on it.

(3) Then a series of--disable-xxx or--enable-xxx This format, is that these affect the post-compilation Library of Things, disable is not compiled xxx,anable is compiled xxx. But here is a note, such as the decoding method you only need to H264, do not want to put other things decoding way to compile in how to do, using:

--disable-decoders and--enable-decoder=h264 combined. In fact, the previous sentence is to disable all the decoding method, and then you compile a certain decoding mode, so that only this kind of decoding method compiled in, this can greatly reduce the static library and can meet the needs of the use. And as for which decoding methods, you can use

./configure--list-decoders to view:/configure--help can see many other executable commands.

Help options:  --help                   Print the message  --list-decoders          Show all available decoders  -- List-encoders          Show all available encoders  --list-hwaccels          Show all available hardware accelerators  -- List-demuxers          Show all available demuxers  --list-muxers            Show all available Muxers  --list-parsers           Show all available parsers  --list-protocols         Show all available Protocols  --list-bsfs              Show All available Bitstream filters  --list-indevs            Show all available input devices  --list-outdevs           Show all available output devices  --list-filters           Show all available filters</span>
As for what to disable, which to enable, so that the optimal compilation, the amount, this may also need to ffmpeg of the various components and their role in the audio and video processing in a better understanding of the line, the ability is limited, is still under exploration.

(4)--enable-cross-compile is allowed to cross-compile,--target-os=darwin is the specified target operating system for the Apple System kernel (Darwin).

(5)--sysroot= is followed by the compilation of the corresponding iOS SDK path, ffmpeg real machine and emulator compilation is different, where the path is correspondingly different. Here's "

/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/ Iphonesimulator7.0.sdk

"is the path to the emulator.

(6)--cc= is followed by the compiler's path, XCODE5 after the default compilation changed to Clang, using GCC seems to be possible.

(7)--arch=i386--cpu=i386 is the choice of the structure of the system and CPU type, the simulator is i386,iphone3gs above:--arch=arm--cpu=cortex-a8,iphone5s for--arch=arm-- Cpu=cortex-a9.

(8) There is no writing here, there is a command:--disable-static, after the use of the compiled is a dynamic library, but Apple seems to not allow the use of dynamic libraries, not to delve into the needs of friends can go to study the ffmpeg of the dynamic library.

Problems with the compilation process, you can go to the FFmpeg directory to view the Config.log file, open to view more detailed information about the error.

3. Use:

After the compilation succeeds, there will be two folders: Include and Lib, a header file, and a library. Add them into the project, and then need to configure the header searchpaths and the library Search Paths, which is the path of the header files and libraries, otherwise the error message "Xxx/xxx.h" file is not found. Then the configuration, or the hint that some files are missing, it may be necessary to add some system dynamic library or framework, but may be compiled at the time of disable some components. After you need to understand the requirements of the project, compile the corresponding libraries.


Reference article: First article

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