UPDATE’13-Jan-21: Include a new gas-preprocessor to address the “R_ABS reloc” issue.
UPDATE’12-Dec-15: Adding compilation steps for armv7s architecture of iPhone 5.
UPDATE’12-Dec-15: Adding compilation steps for armv7s architecture of iPhone 5.
We have been asked by enough associates so that we decided to put together a step-by-step guide on how to prep your Mac if you were to develop an iOS app using FFmpeg libraries. You may be able to piece together on how to do this by googling but nothing complete and error-free. We hope to hold down more ground with this guide.
It might be a good idea to keep this guide up-to-date as time progresses. We will do our best to freshen up the guide once a while. Just don’t yell at us if we decide to skip it every now and then.
Prerequisites:
- Mac OS 10.8.2 with all system update installed as of ’12-Dec-15.
- Xcode Version 4.5.2 (4G2008a)
- Command Line Tools under Xcode >; Preferences >; Downloads >; Components should be checked and installed. You will need the package within later on. Also note that after updating your Xcode you will either be asked to or need to manually update the Command Line Tools.
- Download gas-preprocessor ZIP package. More on how to install this later.
- MacPorts to install: pkg-config by running:
sudo port install pkgconfig
Steps:
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
Install gas-preprocessor
Unless you want to compile without assembler optimizations, please install gas-preprocessor following these steps.
1. Click on the ZIP icon to download gas-preprocessor.
2. Copy
3. Change permission of
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
The options that we decide to set for configure will be the key to the success of making FFmpeg library compilable in Xcode for iOS. You may refer to the detailed options by going in to the
Here is a generated 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.
ffmpeg
folder and type: ./configure --help
Here is a generated 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)
Use the following command for configure:
./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 options for i386 are slightly different:
./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
Assembler optimization will be important on the target device but not on the simulator. Disabling assembler optimization was the quickest way to bypass this block.
Build FFmpeg for i386
Again this command:
make clean && make && make install
Just a note. If you did not
make clean
before another build, you will receive errors like this:cputype (12) does not match previous archive members cputype (7) (all members must match)
So be sure to
make clean
to start anew.Now that we have FFmpeg lib built for all armv7, armv7s and i386, it is now time to
lipo
them all together.Create universal library
The
(Please note that Mountain Lion-supplied
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.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
andlibz.dylib
.
It is about time to put the library to test in code.
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
Go to your
AppDelegate.m
, and add:#include "avformat.h"
And in the
didFinishLaunchingWithOptions
function, add:av_register_all();
There! Should the app be built and the simulation run without problem, congratulations, you are now ready to dive in to develop using FFmpeg on iOS.
Just what I was looking for, excellent!
回复删除There is information on this subject, but this is the most organized and clear that I have found.
Thanks
Mac App Development Services in India
It was so nice article. I was really satisfied by seeing this article. ios online training
回复删除mmorpg oyunlar
回复删除ınstagram takipci satın al
tiktok jeton hilesi
tiktok jeton hilesi
antalya saç ekimi
referans kimliği nedir
İNSTAGRAM TAKİPÇİ SATIN AL
MT2 PVP SERVERLER
Takipçi satın al
PERDE MODELLERİ
回复删除Mobil Onay
TÜRK TELEKOM MOBİL ÖDEME BOZDURMA
nftnasilalinir
ankara evden eve nakliyat
trafik sigortası
dedektör
web sitesi kurma
aşk kitapları
smm panel
回复删除smm panel
iş ilanları
HIRDAVAT
beyazesyateknikservisi.com.tr
servis
Jeton hilesi