Skip to content

Instantly share code, notes, and snippets.

@pa-w
Created August 18, 2014 17:11
Show Gist options
  • Save pa-w/35530c61f737b7599e8f to your computer and use it in GitHub Desktop.
Save pa-w/35530c61f737b7599e8f to your computer and use it in GitHub Desktop.
public virtual void DidOutputSampleBuffer (AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
{
CMFormatDescription formatDescription = sampleBuffer.GetVideoFormatDescription ();
if (connection == videoConnection) {
// Get framerate
CMTime timestamp = sampleBuffer.PresentationTimeStamp;
CalculateFramerateAtTimestamp (timestamp);
// Get frame dimensions (for onscreen display)
if (VideoDimensions.IsEmpty)
VideoDimensions = formatDescription.GetVideoPresentationDimensions (true, false);
// Get the buffer type
if (VideoType == 0)
VideoType = formatDescription.MediaSubType;
// Synchronously process the pixel buffer to de-green it.
using (var pixelBuffer = sampleBuffer.GetImageBuffer ())
ProcessPixelBuffer (pixelBuffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment