Using FFMPEG library with iPhone SDK for video encoding
I need to encode several pictures shot by the iPhone camera into a mp4 video file and I know FFMPEG can do this (the application TimeLapser and ReelMoments do it already). I plan to use this in my app iMotion (available in the appstore).
I successfully install and compile the ffmpeg for the iphone SDK with this link: http://lists.mplayerhq.hu/pipermail/ffmpeg-de开发者_如何学Pythonvel/2009-October/076618.html
But now I'm stuck here in my XCode project. What should I do next to use the FFMPEG library for video encoding? The Apple documentation about external library using is very light and I just can find any tutorial on the web which explains how to do this.
Check out the iFrameExtractor project on github. While this is not exactly what you are looking for, it has scripts for building the ffmpeg libraries and the xcode project links the libraries.
Some more info in this blog post:
http://www.codza.com/extracting-frames-from-movies-on-iphone
In the Project menu, select Edit Active Target "[...]".
Then in Build separator, make sure you have All Configuration selected and do the following:
- search for 'Header Search Paths' and indicate where the FFmpeg headers are located;
- search for 'Library Search Paths' and indicate where the compiled static library binaries (.a files) are located.
This should do it but there's one more neat trick in the latter. You can add a build condition to 'Library Search Paths' so that compiler will use different binaries for different architectures, i.e. you can compile seamlessly for both the Simulator and for the Device. Instruction below.
- With the Library Search Paths row selected, click the the button on left bottom corner of the same window and choose Add Build Setting Condition;
- Where appears 'Any SDK', select 'Any iPhone OS Simulator' and indicate the path to the x86 ffmpeg binaries.
- Repeat the steps above replacing 'Any iPhone OS Simulator' with 'Any iPhone OS Device' and indicate the ARM ffmpeg binaries.
Below is an example of this kind of build settings.
Another option would be to use FFMPEG on a server. Send the images to the server and use PHP w/ ffmpeg to convert the video. With this, you wouldn't have to worry about compiling FFMPEG on the device. Just a thought
精彩评论