Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decode video using CoreMedia.framework on iOS

I need to decode mp4 file and draw it using OpenGL in ios app. I need to extract and decode h264 frames from mp4 file and I heard what it posible to do using CoreMedia. Anybody has any idea how to do it? Any examples of CoreMedia using?

like image 958
Sergey Zenchenko Avatar asked Apr 04 '12 17:04

Sergey Zenchenko


1 Answers

It's not Core Media you're looking for, it's AVFoundation. In particular, you'd use an AVAssetReader to load from your movie and iterate through the frames. You then can upload these frames as OpenGL ES textures either by using glTexImage2D() or (on iOS 5.0) by using the much faster texture caches.

If you don't want to roll your own implementation of this, I have working AVFoundation-based movie loading and processing via OpenGL ES within my GPUImage framework. The GPUImageMovie class encapsulates movie reading and the process of uploading to a texture. If you want to extract that texture for use in your own scene, you can chain a GPUImageTextureOutput to it. Examples of both of these classes can be found in the SimpleVideoFileFilter and CubeExample sample applications within the framework distribution.

You can use this directly, or just look at the code I wrote to perform these same actions within the GPUImageMovie class.

like image 100
Brad Larson Avatar answered Sep 20 '22 06:09

Brad Larson