QTKit Capture - Disabling Audio Or Video When Capturing From a Muxed Device
Q: How can I disable the audio or video stream when capturing from a muxed device?
A: How can I disable the audio or video stream when capturing from a muxed device?
Muxed devices such as DV and HDV Cameras are represented in QTKit Capture by the media type QTMediaTypeMuxed.
To only capture a single stream from the device (for example video only), disable the audio connections on the device input for the capture device by using the QTCaptureConnection method setEnabled: and passing in NO.
Listing 1 Disable Audio Connections From A Muxed Device Input.
QTCaptureDevice *theDefaultMuxedDevice;
QTCaptureDeviceInput *theDeviceInput;
BOOL success;
NSError *error;
...
// get the default muxed device
theDefaultMuxedDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeMuxed];
// open the device
success = [theDefaultMuxedDevice open:&error];
if (YES == success) {
// get the associated device input
theDeviceInput = [QTCaptureDeviceInput deviceInputWithDevice:theDefaultMuxedDevice];
// get the list of owned connections
NSArray *ownedConnections = [theDeviceInput connections];
// disable all the audio connections
for (QTCaptureConnection *connection in ownedConnections) {
if ( [[connection mediaType] isEqualToString:QTMediaTypeSound] ) {
[connection setEnabled:NO];
}
}
} else {
// do something with the error code
}
... |
If you only want to capture audio, disable the QTMediaTypeVideo connections.
References:
Introduction to QTKit Capture Programming Guide
Document Revision History
| Date | Notes |
|---|---|
| 2008-05-19 | New document that describes the use of the setEnabled: method to disable audio or video capture from muxed devices. |
Copyright © 2008 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2008-05-19