Current location - Health Preservation Learning Network - Slimming men and women - How to compile ffmpeg for iphone
How to compile ffmpeg for iphone
Compile FFmpeg under iPhone

mkdir。 /build

# configured for armv7 version

. /Configuration \

-cc =/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc \

-as = ' gas-preprocessor . pl/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc ' \

-sysroot =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK \

-extra-LD flags =-L/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK/usr/lib/system \

- target-os=darwin \

- arch=arm \

- cpu=cortex-a8 \

- extra-cflags='-arch armv7' \

- extra-ldflags='-arch armv7' \

- enable-pic \

-enable- cross-compilation \

- disable-ffmpeg \

- disable-ffplay \

- disable-ffserver \

-disable -doc

# Build for armv7

Make a clean

manufacture

# copy armv7 library

mkdir。 /build/armv7

cp -f ./libavcodec/libavcodec.a。 /build/armv7/libavcodec.a

CP-f ./libavdevice/libavdevice . a。 /build/armv7/libavdevice.a

CP-f ./libavfilter/libavfilter . a。 /build/armv7/libavfilter.a

CP-f ./libavformat/libavformat . a。 /build/armv7/libavformat.a

cp -f ./libavutil/libavutil.a。 /build/armv7/libavutil.a

cp -f ./libswscale/libswscale.a。 /build/armv7/libswscale.a

# configured for armv6 version

. /Configuration \

-cc =/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc \

-as = ' gas-preprocessor . pl/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc ' \

-sysroot =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK \

-extra-LD flags =-L/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK/usr/lib/system \

- target-os=darwin \

- arch=arm \

- cpu=arm 1 176jzf-s \

- extra-cflags='-arch armv6' \

- extra-ldflags='-arch armv6' \

-enable- cross-compilation \

- disable-ffmpeg \

- disable-ffplay \

- disable-ffserver \

-disable -doc

# build for armv6

Make a clean

manufacture

# Copy armv6 library

mkdir。 /build/armv6

cp -f ./libavcodec/libavcodec.a。 /build/armv6/libavcodec.a

CP-f ./libavdevice/libavdevice . a。 /build/armv6/libavdevice.a

CP-f ./libavfilter/libavfilter . a。 /build/armv6/libavfilter.a

CP-f ./libavformat/libavformat . a。 /build/armv6/libavformat.a

cp -f ./libavutil/libavutil.a。 /build/armv6/libavutil.a

cp -f ./libswscale/libswscale.a。 /build/armv6/libswscale.a

# Configured for i386 version

. /Configuration \

-cc =/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/gcc \

-as = ' gas-preprocessor . pl/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/gcc ' \

-sysroot =/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.3 . SDK \

-extra-LD flags =-L/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.3 . SDK/usr/lib/system \

- target-os=darwin \

- arch=i386 \

- cpu=i386 \

- extra-cflags='-arch i386' \

- extra-ldflags='-arch i386' \

-enable- cross-compilation \

- disable-ffmpeg \

- disable-ffplay \

- disable-ffserver \

-disable -doc

# Build for i386

Make a clean

manufacture

# Copy out i386 library

mkdir。 /build/i386

cp -f ./libavcodec/libavcodec.a。 /build/i386/libavcodec.a

CP-f ./libavdevice/libavdevice . a。 /build/i386/libavdevice.a

CP-f ./libavfilter/libavfilter . a。 /build/i386/libavfilter.a

CP-f ./libavformat/libavformat . a。 /build/i386/libavformat.a

cp -f ./libavutil/libavutil.a。 /build/i386/libavutil.a

cp -f ./libswscale/libswscale.a。 /build/i386/libswscale.a

# Making Fat (Universal) libs

Fat output. /build/libavcodec.a -create \

-Arch arm v6. /build/armv6/libavcodec.a \

-arch armv7。 /build/armv7/libavcodec.a \

-Arch i386. /build/i386/libavcodec.a

Fat output. /build/libavdevice.a -create \

-Arch arm v6. /build/armv6/libavdevice.a \

-arch armv7。 /build/armv7/libavdevice.a \

-Arch i386. /build/i386/libavdevice.a

Fat output. /build/libavfilter.a -create \

-Arch arm v6. /build/armv6/libavfilter.a \

-arch armv7。 /build/armv7/libavfilter.a \

-Arch i386. /build/i386/libavfilter.a

Fat output. /build/libavformat.a -create \

-Arch arm v6. /build/armv6/libavformat.a \

-arch armv7。 /build/armv7/libavformat.a \

-Arch i386. /build/i386/libavformat.a

Fat output. /build/libavutil.a -create \

-Arch arm v6. /build/armv6/libavutil.a \

-arch armv7。 /build/armv7/libavutil.a \

-Arch i386. /build/i386/libavutil.a

Fat output. /build/libswscale.a -create \

-Arch arm v6. /build/armv6/libswscale.a \

-arch armv7。 /build/armv7/libswscale.a \

-Arch i386. /build/i386/libswscale.a

The compiler configuration of i386 above, that is, the emulator, is not necessary. Here is another configuration method:

. /Configuration \

- disable-bzlib \

- disable-mmx \

- disable-doc \

- disable-ffmpeg \

- disable-ffplay \

- disable-ffserver \

-cc =/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/i686-apple-Darwin 10-gcc-4 . 2 . 1 \

-as = ' gas-preprocessor/gas-preprocessor . pl/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/i686-apple-Darwin 10-gcc-4 . 2 . 1 ' \

-sysroot =/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.0 . SDK \

-extra-c flags = '-f message-length = 0-pipe-Wno-trigraphs-fpascal-strings-O0-fasm-blocks-Wreturn-type-Wunused-variable-D _ _ IPHONE _ OS _ VERSION _ M IN _ REQ UIRED = 30000-isysroot/Developer/Platforms/IPHONE simulator . platform/Developer/SDKs/IPHONE simulator 4.0 . SDK-f visibility = hidden-mmacosx-VERSION-MIN = 10.5- 1

Another article

Move the value FFMPEG to iPhone or MAC OS/X.

For a detailed description of FFMPEG, please refer to the relevant documents on the Internet. Here we only talk about the process of FFMPEG migrating to iPhone or Mac OS/X and related matters needing attention.

The functions of FFMPEG are quite powerful, including FFServer, FFPlay, FFMPEG, AVCODEC, AVDevice, AVFormat, AVutil, SWScale and so on. In the complete FFMPEG packet. Among them, ffserver, ffplay and ffmpeg are application programs, which are basically useless for those of us who are engaged in software development. Avcodec is the encryption and decoding library, avformat is the format library, avutil is the basic library (but we seldom use it), and swscale is the image processing library. So what we want is to transfer the value of these four libraries: avcodec, avformat, avutil and swscale.

The process of transferring value to Mac OS/X:

I. Configuration

. /configure-prefix =/Developer/usr-cc =/Developer/usr/bin/ gcc-4.0-enable-GPL-enable-shared-disable-IPv6-enable-SW scale-enable-zlib-enable-bzlib-disable-ffmpeg-disable-ff play-disable-ff server-disable-vhook

Second, the preparation

manufacture

Third, installation

Carry out installation

Note: /Developer/usr above is the target directory. If your Xcode is installed by default, you can compile and debug your code in Xcode after installation.

The process of moving the value to the simulated iPhone platform under Mac OS/X:

I. Configuration

. /configure-prefix =/Developer/usr-disable-debug-cc =/Developer/usr/bin/i686-apple-Darwin 9-gcc-4 . 0 . 1 -enable-GPL-enable-static-disable-shared-disable-IPv6-enable-swscale-enable-zlib-enable-bzlib-disable-ffmpeg-disable-ff play-disable-ff server-disable-v hook-enable-pthreads

Among them: you can also add-enable-share, so that it can compile and generate dynamic libraries, which will be used in future programming. -Installation directory of prefix settings. If-enable-shared is not added during configuration, the static link will not generate three dynamic libraries. At the same time, the execution files generated by ffplay and ffmpeg are also relatively large, because they can be executed without the support of dynamic libraries. But it is not conducive to secondary development, so I can also consider using dynamic links.

Second, the preparation

manufacture

Third, installation

Carry out installation

After installation, you will see three directories in /usr/local/ffmpeg.

Lib dynamic link library location

Contains header files for programming.

The directory where the bin executable file is located.

In order to facilitate future programming, we copied three link libraries libavcodec. solibavformat。 Solibavuutil.so in lib to /usr/lib. Copy the ffmpeg directory under the include directory to /usr/include. You can play audio or video files by executing ffplay in the bin directory. For example, play1.mp3.

. /ffplay 1.mp3

In addition, there are two files in the bin directory: ffmpeg and ffserver.

Ffmpeg is a good tool for video and audio format conversion. There are many documents about it on the Internet. If you don't want to generate ffserver, just add-disable -ffserver when. /configure。

Note: /Developer/usr above is the target directory. If your Xcode is installed by default, you can compile your code in Xcode and download it to the emulator after installation.

The process of transferring value to iPhone platform:

I. Configuration

. /configure-enable-cross-compile-cross-prefix =/Developer/Platforms/iphone OS . platform/usr/bin/-cc =/Developer/Platforms/iphone OS . platform/ Developer/usr/bin/arm-apple-Darwin 9-gcc-4 . 0 . 1-prefix =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 2.0 . SDK/ usr-extra-cflags = "-isy root/Developer/Platforms/iphone OS . platform/platform

Second, the preparation

manufacture

Third, installation

Carry out installation

Note: above/developer/platform /iphoneOS. Platform/developer/usr/bin/ is the target directory. If your Xcode is installed by default, you can compile your code in Xcode and download it to the emulator after installation.

Related instructions:

If static libraries are used in ffmpeg, there will be some connection errors. So please choose dynamic library when installing ffmpeg library.

Ok, now we know how to move ffmpeg to iPhone and combine ffmpeg library with Xcode. Of course, if your Xcode tool is not installed by default, please change the related directory options.