4

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 an API that 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.

Could anybody suggest how I can take a encoded in-memory buffer and decode it using hardware to another in-memory buffer?

Thanks

Mark
  • 6,108
  • 3
  • 34
  • 49
Cthutu
  • 8,713
  • 7
  • 33
  • 49
  • Does this answer your question? [How to use VideoToolbox to decompress H.264 video stream](https://stackoverflow.com/questions/29525000/how-to-use-videotoolbox-to-decompress-h-264-video-stream) – Troy Mar 08 '21 at 09:59

1 Answers1

1

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.

Mark
  • 6,108
  • 3
  • 34
  • 49
  • Thanks for your comment. I am using i-frames for now which don't use information on the previous frame. I wanted to take advantage of the hardware decoding. – Cthutu May 15 '12 at 14:22
  • If you are sure about that, then I think that the AVAssetReader class is what you want. Good Luck. – Mark May 15 '12 at 14:51
  • It's the first step to a real-time video stream and by real-time I mean REAL real-time, not HTTP Live Streaming. I have a single frame .264 file being sent over the network and I need to decode it. And luck is definitely what I need :) – Cthutu May 15 '12 at 15:12