iosh.264

Decoding single frames encoded to H.264 on iOS


I'm encoding a single generated image on a PC to H.264, sending it over the network to the iPad, and I want to decode it. The cycle on the iPad side will be:

  1. Grab frame from network
  2. Decode it.
  3. Display it.

However, I can't find any way, given a single buffer of a encoded frame, I can decode to the original image. I want to take advantage of the hardware decoding on the iPad.

My plan of last resort is to create a memory-mapped file, write that single frame to that file, and use that file as input into MPMoviePlayerController. This is a really hacky solution.

How can I take an encoded in-memory buffer and decode it using hardware to another in-memory buffer?


Solution

  • This sounds like a job more suited to JPG or PNG on the PC side. H.264 encoding frames don't necessarily stand alone like PNG or JPG. They depend on the last key frame and the intervening delta frames.

    If you still want H.264 then try looking at AVFoundation framework and specifically the AVAssetReader class. AVFoundation is the replacement for the old QuickTime APIs. A good place to start is the WWDC '11 videos from session 405 and session 415. The AVEditDemoIPad code isn't available unless you attended WWDC last year, but the Asset demo is available on iTunes.