10

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-devel/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.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • 2
    Be sure to comply with the LGPL if you're using ffmpeg. – Kenny Winker Nov 05 '09 at 11:15
  • 1
    Also, if you are planning on submitting your application to the App Store be aware of the legal implications of selling software that uses ffmpeg. It may be infringing on patents in your jurisdiction (http://ffmpeg.org/legal.html). This may also impact your ability to get approval on the App Store. – Nick Haddad Nov 05 '09 at 14:24
  • 1
    Yes, you will need to release either your source code or your object code for your application in order to comply with the LGPL when using ffmpeg as a static library: http://huyzing.com/2009/08/24/compatibility-between-the-iphone-app-store-and-the-lgpl/ – Brad Larson Nov 05 '09 at 15:17
  • 1
    iOS already supports h.264 encoding with builtin hardware via the AVAssetWriter class. See http://stackoverflow.com/questions/2563212/create-video-in-iphone/17138410#17138410 – MoDJ Jun 16 '13 at 23:59

3 Answers3

11

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

lajos
  • 25,525
  • 19
  • 65
  • 75
  • 1
    I've tried to get it working, but when I do ./build_universal the "lipo"-instructions in the file seem to fail and I end up without the *.a files. I get this error: `lipo: specifed architecture type (armv6) for file (armv6/libavcodec.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))` for each of the lipo commands – Robin Rye Aug 09 '11 at 09:02
  • To fix that follow this thread http://stackoverflow.com/questions/6994151/problem-compiling-ffmpeg-for-iframeextractor – deimus Jun 21 '12 at 11:03
8

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.

alt text

Spooky
  • 2,966
  • 8
  • 27
  • 41
jpedroso
  • 589
  • 3
  • 4
4

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

Tony
  • 656
  • 8
  • 20