Hackers' corner: enhancing the iPad 2 camera

Now that iOS 5.0.1 has become hackable, I've been continuously receiving requests to make my previous, strictly iOS4-specific iPhone 3GS / 4 video camera enhancer tool (available in Cydia: see THIS) iOS 5-compliant.

Having successfully closed a major project I've been working on for months, I immediately moved to devoting my free time to updating my tool.

At first, I've checked out the video recording of the iPad 2 using the back (720p) camera. (You can expect a tool for at least the iPhone 4 and the 4S next week. Dunno if I update the 3G S code – it'll depend on my free time; after all, I'll fly to Barcelona, to the MWC, on Saturday.)

Under iOS4, the parameter file you'll needed to hack AVCaptureSession.plist and AVCapture.plist, both stored under /System/Library/Frameworks/AVFoundation.framework/Nxx/ (where xx depends on the phone model; 90 for the iPhone 4 etc.)

As opposed to iOS4, where you needed to edit both the above files, under iOS5, there's only one file to edit (AVCaptureSession.plist) and it's in a completely different directory: /System/Library/PrivateFrameworks/MediaToolbox.framework/K93/

There's only one place you need to edit: AVCaptureDevices / AVCaptureSessionPresetHigh; all the other dictionary entries are for different purposes (e.g., front camera, videoconference settings etc.)

Upping the resolution

The sensor itself is of the resolution 720p (=1280x720). I've played a bit with increasing the config values (Sensor and Capture values) by increasing them by 200. All I got was a black recording. That is, unlike with the iPhone 3G S / 4, you cannot increase the resolution at all.

Increasing the frame rate

If you compare the dictionary entry, AVCaptureDevices / AVCaptureSessionPresetHigh, we need to edit, you may notice it completely lacks the  MaxFrameRate and  MinFrameRate dictionary entries. These entries are present in, say, the AVCaptureSessionPresetConferencing dictionary entry, setting both these values to 15. (In a videoconference, you don't necessarily need fluid 30 fps.)

I've added the two dictionary entries to  AVCaptureSessionPresetHigh (you can simply paste them right after <key>LiveSourceOptions</key><dict>) and played with the parameters. Anything under 30 (fps) was adhered to; for example, I've made videos with 2 fps (by supplying “2” as the two parameters).

I've also tried increasing the framerate from the default 30 to both 60 and 120. Unfortunately, it's not possible at all: the footage recorded will still be 30 fps, even in lower-resolution modes (also checked this at 320*240 and 320*480). That is, you can't make a high-speed e.g. benchmarking camera out of your iPad 2 (unlike with several P&S cameras like the Nikon P300), unfortunately. It seems the hardware (the sensor itself) only allows for 30 fps reading speed – after all, the reading speed of sensors isn't infinite, unfortunately.

Decreasing the bitrate

This works: you can easily decrease the, by default, pretty high encoding bitrate. It's done in exactly the same way as under iOS4: in the dictionary entry, look for the entry VideoCompressionProperties and, in there, AverageDataRate. You can supply any value there. You might want to do this if you want to make your iPad a long-time video recorder. However, I don't think the iPad is perfectly aimed for these tasks (even an iPhone 4 is much easier to use as a camera, say, put in a corner of a room to record everything happening) so I don't release a setter tool to set exactly this parameter. (If you REALLY need this, please tell me in the Comments section below. [No private e-mails please.] If I do get a sufficient number of requests, I may change my mind.)

Final word

All in all, as opposed to the case of the iPhone 3GS, the iPhone 4 (and, I hope, the 4S), I don't see much point in hacking these parameters. Therefore, I don't release a separate hacking tool to set the fps / bit rate values either.

Master your iPhone in one minute a day: Sign up here to get our FREE Tip of the Day delivered right to your inbox.

<p>Werner Ruotsalainen is an iOS and Java programming lecturer who is well-versed in programming, hacking, operating systems, and programming languages. Werner tries to generate unique articles on subjects not widely discussed. Some of his articles are highly technical and are intended for other programmers and coders.</p>
<p>Werner also is interested in photography and videography. He is a frequent contributor to not only mobile and computing publications, but also photo and video forums. He loves swimming, skiing, going to the gym, and using his iPads. English is one of several languages he speaks.</p>