I'm using AVCaptureSession to preview video in an augmented reality type app on iPhone. Since I'm also drawing OpenGL graphics on top of the video preview, the app is quite energy consuming. I want to minimize cpu usage to save battery.
When I check the app with Instruments/Energy usage, I see that a considerable portion (~20%) of the CPU is "wasted" on audio processing. If I remove my capture session, audio processing takes no CPU, as expected.
I don't understand why the capture session is doing audio processing since I haven't added any audio device input into it. Here's how I set up the session:
if(!captureSession) {
captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (videoDevice) {
NSError *error;
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (!error) {
if ([captureSession canAddInput:videoIn]) {
[captureSession addInput:videoIn];
}
}
}
}
if(!previewLayer) {
previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession];
[previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
}
CGRect layerRect = [[viewBg layer] bounds];
[previewLayer setBounds:layerRect];
[previewLayer setPosition:CGPointMake(CGRectGetMidX(layerRect), CGRectGetMidY(layerRect))];
[[viewBg layer] addSublayer:previewLayer];
[captureSession startRunning];
Is there a way to disable audio (input) altogether or how could I get rid of the audio processing CPU usage while previewing video input?