Skip to content

Instantly share code, notes, and snippets.

@petershine
Created October 29, 2015 06:05
Show Gist options
  • Save petershine/49a826509cc7045d81f6 to your computer and use it in GitHub Desktop.
Save petershine/49a826509cc7045d81f6 to your computer and use it in GitHub Desktop.
Essential snippet for decompressing sample into CVImageBufferRef
{
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(compressedSample);
static VTDecompressionSessionRef decompressionSession;
if (decompressionSession == NULL) {
VTDecompressionSessionCreate
(NULL,
formatDescription,
NULL,
NULL,
NULL,
&decompressionSession);
}
VTDecompressionSessionDecodeFrameWithOutputHandler
(decompressionSession,
compressedSample,
kVTDecodeFrame_EnableAsynchronousDecompression,
NULL,
^(OSStatus status,
VTDecodeInfoFlags infoFlags,
CVImageBufferRef _Nullable imageBuffer,
CMTime presentationTimeStamp,
CMTime presentationDuration) {
//MARK: New CMSampleBufferRef may have to be created for other uses
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment