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: 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

Back to Top 

Document Revision History

DateNotes
2008-05-19First Version

Posted: 2008-05-19


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.