AVCaptureVideoDataOutput Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AVFoundation.framework |
| Availability | Available in iOS 4.0 and later. |
| Declared in | AVCaptureOutput.h |
Overview
AVCaptureVideoDataOutput is a concrete sub-class of AVCaptureOutput you use to process uncompressed frames from the video being captured, or to access compressed frames.
An instance of AVCaptureVideoDataOutput produces video frames you can process using other media APIs. You can access the frames with the captureOutput:didOutputSampleBuffer:fromConnection: delegate method.
Tasks
Configuration
-
videoSettingsproperty -
alwaysDiscardsLateVideoFramesproperty -
minFrameDurationproperty Deprecated in iOS 5.0
Managing the Delegate
-
– setSampleBufferDelegate:queue: -
sampleBufferDelegateproperty -
sampleBufferCallbackQueueproperty
Retrieving Supported Video Types
-
availableVideoCVPixelFormatTypesproperty -
availableVideoCodecTypesproperty
Properties
alwaysDiscardsLateVideoFrames
Indicates whether video frames are dropped if they arrive late.
Discussion
When the value of this property is YES, the object immediately discards frames that are captured while the dispatch queue handling existing frames is blocked in the captureOutput:didOutputSampleBuffer:fromConnection: delegate method.
When the value of this property is NO, delegates are allowed more time to process old frames before new frames are discarded, but application memory usage may increase significantly as a result.
The default is YES.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCaptureOutput.havailableVideoCodecTypes
Indicates the supported video codec formats that can be specified in videoSettings. (read-only)
Discussion
The value of this property is an array of NSString objects you can use as values for the AVVideoCodecKey in the videoSettings property. The first format in the returned list is the most efficient output format.
Availability
- Available in iOS 5.0 and later.
Declared In
AVCaptureOutput.havailableVideoCVPixelFormatTypes
Indicates the supported video pixel formats that can be specified in videoSettings. (read-only)
Discussion
The value of this property is an array of NSNumber objects you can use as values for the kCVPixelBufferPixelFormatTypeKey in the videoSettings property. The first format in the returned list is the most efficient output format.
Availability
- Available in iOS 5.0 and later.
Declared In
AVCaptureOutput.hsampleBufferCallbackQueue
The queue on which delegate callbacks should be invoked (read-only)
Discussion
You set the queue using setSampleBufferDelegate:queue:.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCaptureOutput.hsampleBufferDelegate
The capture object’s delegate. (read-only)
Discussion
The delegate receives sample buffers after they are captured.
You set the delegate using setSampleBufferDelegate:queue:.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCaptureOutput.hvideoSettings
The compression settings for the output.
Discussion
The dictionary contains values for compression settings keys defined in AVVideoSettings.h, or pixel buffer attributes keys defined in <CoreVideo/CVPixelBuffer.h> (see CVPixelBufferRef). The only key currently supported is the kCVPixelBufferPixelFormatTypeKey key.
To get possible values for the supported video pixel formats (kCVPixelBufferPixelFormatTypeKey) and video codec formats (AVVideoCodecKey), see availableVideoCVPixelFormatTypes and availableVideoCodecTypes respectively.
To receive samples in their device native format, set this property to nil:
AVCaptureVideoDataOutput *myVideoOutput; // assume this exists |
myVideoOutput.videoSettings = nil; // receives samples in device format |
If you set this property to nil and then subsequently query it, you will get a dictionary reflecting the settings used by the capture sessions’s current sessionPreset.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCaptureOutput.hInstance Methods
setSampleBufferDelegate:queue:
Sets the sample buffer delegate and the queue on which callbacks should be invoked.
Parameters
- sampleBufferDelegate
An object conforming to the
AVCaptureVideoDataOutputSampleBufferDelegateprotocol that will receive sample buffers after they are captured.- sampleBufferCallbackQueue
The queue on which callbacks should be invoked. You must use a serial dispatch queue, to guarantee that video frames will be delivered in order.
The sampleBufferCallbackQueue parameter may not be
NULL, except when setting the sampleBufferDelegate tonil.
Discussion
When a new video sample buffer is captured, it is sent to the sample buffer delegate using captureOutput:didOutputSampleBuffer:fromConnection:. All delegate methods are invoked on the specified dispatch queue.
If the queue is blocked when new frames are captured, those frames will be automatically dropped at a time determined by the value of the alwaysDiscardsLateVideoFrames property. This allows you to process existing frames on the same queue without having to manage the potential memory usage increases that would otherwise occur when that processing is unable to keep up with the rate of incoming frames.
If your frame processing is consistently unable to keep up with the rate of incoming frames, you should consider using the minFrameDuration property, which will generally yield better performance characteristics and more consistent frame rates than frame dropping alone.
If you need to minimize the chances of frames being dropped, you should specify a queue on which a sufficiently small amount of processing is being done outside of receiving sample buffers. However, if you migrate extra processing to another queue, you are responsible for ensuring that memory usage does not grow without bound from frames that have not been processed.
Special Considerations
This method uses dispatch_retain and dispatch_release to manage the queue.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCaptureOutput.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-12-13)