Ad

Our DNA is written in Swift
Jump

DTVideoEncoder

I’ve been approached by several parties asking for a component to capture live video. I did my homework but had to find that without access to a hardware-based video encoder it is not possible to get real time frame rates on iPhones.

Interviewing the maker of the ShowTime Video Recorder app for iPhone 2G and 3G enlightened me a bit as to what tricks they used to pull off their app. They use AVI containers for JPEG frames and PCM audio. Other people seem to have a bit of success with compiling FFMPEG on the iPhone. But generally MPEG4 does not use less CPU power than encoding JPEGs, it uses MORE, causing even worse frame rates for live video.

And that’s ignoring the licensing problems you get when selling an app that has a h.264 encoder. A double-whammy in non-feasability for FFMPEG, all the more reason to find out the truth of the matter.

So we set out to build DTVideoEncoder to see for ourselves what kind of performance we can get. Unfortunately it turns out that even on a 3GS we are getting a maximum frame rate of 5 frames per second when encoding live screenshots. Polar Bear Farm hinted that they are only able to get their performance (of around 6 fps) because of heavy assembly-optimizing the JPEG compression library . But they communicated a disinterest in licensing it for us to put into a sellable component.

So we were stuck. Until actually somebody told us that instead of live video encoding he just wanted to add JPEG files to an AVI container plus audio. Because the JPEG files where already compressed  he would not face the bottleneck of JPEG compression. Suddenly this specific use case reinvigorated the project.

Kris Harris – maker of the 8 Track Mind iPhone game – went back into the depths of the AVI documentation and polished up DTVideoEncoder to be usable for offline encoding and added the requested capability of adding an existing PCM audio file as soundtrack. Kris is a great developer and his code is awesome, I’m glad to have him on my Dr. Touch Core Team.

Here’s a demonstration of the Demo app that you get with the component.

DTVideoEncoder does not have any external dependencies. Because the external JPEG compression library did not yield any performance improvement over what’s built into the SDK we chose to go with the on-board method.

Hours and hours worth of research and coding went into in this simple to use component to warrant a price tag of several hundred dollars. But because of the limited utility we we set the price to the lower end of the spectrum, at 250 Euros. It might enable one or more interesting uses of offline-video on iPhone or iPad.

Play

Tagged as:

Categories: Parts

Leave a Comment