FFMPEG集成在iphone / ipad项目中 [英] FFMPEG integration on iphone/ ipad project

查看:157
本文介绍了FFMPEG集成在iphone / ipad项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何使用Xcode 4将FFMPEG整合到我的iphone / ipad project.im中。
i搜索了很多但没有找到任何有用的链接.please告诉我一步一步的过程来整合FFMpeg谢谢,

解决方案

先决条件



MacPorts要安装:打开终端并键入


sudo端口安装pkgconfig


启动终端并下载FFmpeg源



目录的位置取决于您的个人偏好,我选择将其保存在我的主文件夹下的ffmpeg文件夹中,以便以后轻松访问。


git clone git://source.ffmpeg.org/ffmpeg.git〜/ ffmpeg


在我们之前进一步,我们需要提前思考,意识到我们可能会在Mac本身进行一些模拟,以及对我的实际测试电话。我们需要做的是,我们需要构建3种架构的图书馆:armv7(iPhone 3Gs或更高版本),armv7(iPhone 5)和i386(iPhone模拟器)。



我们在ffmpeg文件夹中创建一些文件夹,以容纳3种不同的构建,以便我们可以将它们合并成一个通用版本。


cd ffmpeg
mkdir armv7
mkdir armv7s
mkdir i386
mkdir -p通用/ lib


安装气体预处理


  1. 点击ZIP文件下载气体预处理器。

  2. 将gas-preprocessor.pl复制到/ usr / bin目录。

  3. 更改气体预处理器的权限.pl通过将权限设置为Read&

配置FFmpeg for armv7 build



在配置之前,
您可以参阅ffmpeg文件夹中的详细选项,然后输入:


./configure --help


可供您参考的选项列表: FFmpeg配置选项。根据您想要使用FFmpeg的内容,组件选项取决于您。



现在运行以下配置选项:


./ configure \
--prefix = armv7 \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-avresample \
--enable-cross-compile \
--sysroot =/ Applications / Xcode.app / Contents / Developer / Platforms / iPhoneOS.platform / Developer / SDKs / iPhoneOS6.0.sdk
\
--target-os = darwin \
--cc =/ Applications / Xcode.app / Contents / Developer / Platforms / iPhoneOS.platform / Developer / usr / bin / gcc
\
--extra -cflags = - arch armv7 -mfpu = neon -miphoneos-version-min = 6.0\
--extra-ldflags = - arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms /iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
-miphoneos-version-min = 6.0\
--arch = arm \
--cpu = cortex-a9 \
--enable-pic \


您可能会收到以下警告:


警告:编译器不指示浮点型ABI, p>

不用担心。你应该继续下一步。



为armv7构建FFmpeg



运行构建命令:


make clean&&制作&& make install


现在,您应该可以看到文件填充在 ffmpeg / armv7 文件夹中。



配置并安装armv7s架构(iPhone 5)的FFmpeg



/ configure \
--prefix = armv7s \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-avresample \
--enable-cross-compile \
--sysroot =/ Applications / Xcode .app / Contents / Developer / Platforms / iPhoneOS.platform / Developer / SDKs / iPhoneOS6.0.sdk
\
--target-os = darwin \
--cc = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
\
--extra-cflags = - arch armv7s -mfpu = neon -miphoneos-version-min = 6.0\
--extra-ldflags = - arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6。 0.sdk
-miphoneos-version-min = 6.0\
--arch = arm \
--cpu = cortex-a9 \
--enable- pic \


然后搭建:


使清洁&安培;&安培;制作&& make install


为i386构建配置FFmpeg



< blockquote>

./ 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 / iPhoneSimulator6.0.sdk
\
--target-os = darwin \
--cc =/ Applications / Xcode.app / Contents / Developer / Platforms / iPhoneSimulator.platform / Developer / usr / bin / gcc
\
--extra-cflags = - arch i386\
--extra-ldflags = - arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk
\
--arch = i386 \
--cpu = i386 \
--enable-pic \
--dis可以使用asm \


请注意最后一个--disable-asm标签。如果您忘记添加此标签,您可能会收到此错误:


cc1:后端错误:寄存器中的寄存器出现
分配! make:*** [libavcodec / h264_cabac.o]错误1


为i386构建FFmpeg


make clean&&制作&& make install


创建通用库



lipo命令(假设你仍然在ffmpeg文件夹下):
(请注意,Mountain Lion提供的lipo至今没有关于armv7的内容,所以我们需要使用xcrun来找到SDK提供的lipo。 )


cd armv7 / lib for * .a do cd ../ .. xcrun -sdk iphoneos lipo
- 输出通用/ lib / $ file -create \
-arch armv7 armv7 / lib / $ file \
-arch armv7s armv7s / lib / $ file \
-arch i386 i386 / lib / $ file echoUniversal $ file created。 cd - done cd ../..


在通用/ lib下,你会发现所有的FAT库都是新鲜出炉的。我们现在把注意力链接到这些静态库到Xcode项目。



如果你收到这样的错误错误:没有开发人员目录在/ Developer ?然后键入


sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer


在Xcode中链接静态库



首先,我们拉.a文件。



使用Xcode创建一个新的空应用程序。分配产品名称和公司标识符。然后单击下一步并保存项目。
ffmpeg / universal / lib 下找到我们创建的通用库(.a文件)。
将.a文件拖动到项目导航器窗格中的框架文件夹中。
勾选将项目复制到目标组的文件夹(如果需要)。然后单击完成。



现在我们来处理包含文件。



找到 FFMPEG / ARMv7的/包含
将该文件夹的内容拖放到项目导航器窗格中的项目名称文件夹中。
再次,勾选将项目复制到目标组的文件夹(如果需要)。然后单击完成。



最后,我们需要为项目设置标题搜索路径



单击项目导航器窗格中的项目
在屏幕中间的标准编辑器中,单击构建设置。
搜索标题搜索路径
添加您的项目路径并将其设置为递归。即 $(SRCROOT)
单击构建阶段。
在链接二进制与库下,添加 libbz2.dylib libz.dylib



测试和验证图书馆的工作



我们不会在这里深入。只是为了验证图书馆的功能。
转到AppDelegate.m,然后添加:



#includeavformat.h



didFinishLaunchingWithOptions 函数中,添加:


av_register_all ();


如果你想得到这个错误意味着



架构i386的未定义符号:
_iconv,从:
_mail_iconv在libmailcore.a(charconv.o)
_iconv_open,引用:
_charconv在libmailcore.a(charconv.o)
_charconv_buffer在libmailcore.a(charconv.o)
_iconv_close,引用来自:
_charconv在libmailcore.a(charconv.o )
_charconv_buffer在libmailcore.a(charconv.o)
ld:没有找到符号i386
collect2:ld返回1退出状态



然后添加 libiconv.dylib 框架



你现在已经准备好了o在iOS上使用FFmpeg进行开发。


Can any One Tell me how do i integrate FFMPEG in my iphone/ ipad project.i m using Xcode 4. i searched a lot but did not find any useful Link .please tell me step by step procedure to integrate FFMpeg in my project.

thanks,

解决方案

Prerequisites

MacPorts to install:open terminal and type

sudo port install pkgconfig

Launch Terminal and download FFmpeg source

The location of the directory is up to your personal preference and I chose to save it in a ffmpeg folder under my Home folder for easy access later on.

git clone git://source.ffmpeg.org/ffmpeg.git ~/ffmpeg

Before we go further, we need to think ahead and realize that we are likely to do some simulation on Mac itself along with actual testing on iPhone. What we need to do is that we need to build libraries for 3 architectures: armv7 (iPhone 3Gs or later), armv7s (iPhone 5) and i386 (iPhone Simulator).

Let’s create some folders inside ffmpeg folder to hold 3 different builds so that we can lipo those together into one universal build.

cd ffmpeg mkdir armv7 mkdir armv7s mkdir i386 mkdir -p universal/lib

To Install gas-preprocessor

  1. Click on the ZIP icon to download gas-preprocessor.
  2. Copy gas-preprocessor.pl to /usr/bin directory.
  3. Change permission of gas-preprocessor.pl by setting the privilege to Read & Write for all.

Configure FFmpeg for armv7 build

Before configuring, You may refer to the detailed options by going in to the ffmpeg folder and type:

./configure --help

list of options for your reference: FFmpeg Configure Options. The "Components options" will be up to you depending on what you want to do with FFmpeg.

Now run the following configure options:

./configure \ --prefix=armv7 \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --enable-avresample \ --enable-cross-compile \ --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \ --target-os=darwin \ --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" \ --extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-min=6.0" \ --extra-ldflags="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=6.0" \ --arch=arm \ --cpu=cortex-a9 \ --enable-pic \

You may get a warning such as:

WARNING: Compiler does not indicate floating-point ABI, guessing soft.

No worries. You should be fine to continue to next steps.

Build FFmpeg for armv7

Run the build commands:

make clean && make && make install

Now you should be able to see files are populated inside the ffmpeg/armv7 folder. We now move onto building for armv7s for iPhone 5.

Configure and Install FFmpeg for armv7s architecture (iPhone 5)

. /configure \ --prefix=armv7s \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --enable-avresample \ --enable-cross-compile \ --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" \ --target-os=darwin \ --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" \ --extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=6.0" \ --extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=6.0" \ --arch=arm \ --cpu=cortex-a9 \ --enable-pic \

Then build with:

make clean && make && make install

Configure FFmpeg for i386 build

./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/iPhoneSimulator6.0.sdk" \ --target-os=darwin \ --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc" \ --extra-cflags="-arch i386" \ --extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk" \ --arch=i386 \ --cpu=i386 \ --enable-pic \ --disable-asm \

Please note the last --disable-asm tag. If you forget to include this tag, you will likely to receive this error:

cc1: error in backend: Ran out of registers during register allocation! make: *** [libavcodec/h264_cabac.o] Error 1

Build FFmpeg for i386

make clean && make && make install

Create universal library

The lipo commands (assuming you are still under the ffmpeg folder): (Please note that Mountain Lion-supplied lipo knows nothing about armv7s as of yet. So we need to use xcrun to find the lipo supplied with the SDK.)

cd armv7/lib for file in *.a do cd ../.. xcrun -sdk iphoneos lipo -output universal/lib/$file -create \ -arch armv7 armv7/lib/$file \ -arch armv7s armv7s/lib/$file \ -arch i386 i386/lib/$file echo "Universal $file created." cd - done cd ../..

Look under universal/lib, you will find all FAT libs freshly baked there. We now turn our attention to linking these static libraries to the Xcode project.

if you are getting error like this Error: No developer directory found at /Developer"? then type

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Linking static libraries in Xcode

Firstly, we pull in the .a files.

Create a new Empty Application using Xcode. Assign a Product Name and Company Identifier. Then click Next and save the project. Locate the universal libs that we created (the .a files) under ffmpeg/universal/lib. Drag the .a files into the Frameworks folder in the Project Navigator pane. Tick "Copy items into destination group’s folder (if needed)". And click Finish.

Now we take care of the include files.

Locate the include files under ffmpeg/armv7/include. Drag and drop the content of that folder onto the Project Name folder in the Project Navigator pane. Again, tick "Copy items into destination group’s folder (if needed)". Then click Finish.

Finally, we need to set the Header Search Paths for the project.

Click on the Project in the Project Navigator pane. In the Standard Editor in the middle of the screen, click on Build Settings. Search for "Header Search Paths". Add your project path and set it to Recursive. i.e. $(SRCROOT) Click on Build Phases. Under Link Binary With Libraries, add libbz2.dylib and libz.dylib.

Test and verify the working of library

We are not going to be in-depth here. Just to verify that the library is functioning. Go to your AppDelegate.m, and add:

> #include "avformat.h"

And in the didFinishLaunchingWithOptions function, add:

av_register_all();

if suppose you are getting this errors means

Undefined symbols for architecture i386: "_iconv", referenced from: _mail_iconv in libmailcore.a(charconv.o) "_iconv_open", referenced from: _charconv in libmailcore.a(charconv.o) _charconv_buffer in libmailcore.a(charconv.o) "_iconv_close", referenced from: _charconv in libmailcore.a(charconv.o) _charconv_buffer in libmailcore.a(charconv.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status

then add libiconv.dylib framework

you are now ready to dive in to develop using FFmpeg on iOS.

这篇关于FFMPEG集成在iphone / ipad项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆