c++macosavfoundationcore-video

OSX Native API Video Decoding C++


Recently, I completed an audio decoding task using Apple Core Audio C++ API.

Now I am interested in decoding and getting raw uncompressed data of frames of a video file again with native OSX API with C++ (the analog of DirectShow or Media Foundation on Windows OS).

I have looked at available APIs (AVFoundation, Core Video, etc.) but couldn't find the framework which will do the job and is accessible through C++.

So my question which is the most suitable framework to pick up for this task?


Solution

  • You can read raw video data from a file using AVFoundation's AVAssetReader.

    You create an AVAssetReader, add a AVAssetReaderTrackOutput with nil output settings then call copyNextSampleBuffer() until finished.

    However, unless you've got very specific needs, you're unlikely to find the raw codec video data very useful. Are you trying to display the video? In that case AVPlayerLayer / AVPlayer (AVFoundation once again) are probably what you're looking for. If you want something lower level, CoreMedia/VideoToolbox may be for you. AVFoundation is an objective c framework so you'll be using objective-c++, while CoreMedia and VideoToolbox are C frameworks.