AVFoundation视频录制音量控制

时间:2015-05-18 10:13:47

标签: ios avfoundation avcapturesession

我正在使用具有视频录制功能的应用,用户可以在其中调整音量。我使用AVFoundation完成了它。我已初始化AVCaptureSession并在其中添加了AVCaptureAudioDataOutputAVCaptureVideoDataOutput作为音频和视频输出。我还在这里附上一段代码。

    AVCaptureSession *session = _captureSession;
    if (![session.sessionPreset isEqualToString:_captureSessionPreset]) {
    if ([session canSetSessionPreset:_captureSessionPreset]) {
        session.sessionPreset = _captureSessionPreset;
    } else {
        newError = [VideoRecorder createError:@"Cannot set session preset"];
    }
}
_videoOutputAdded = NO;
if (self.videoConfiguration.enabled) {
    if (_videoOutput == nil) {
        _videoOutput = [[AVCaptureVideoDataOutput alloc] init];
        _videoOutput.alwaysDiscardsLateVideoFrames = NO;
        [_videoOutput setSampleBufferDelegate:self queue:_sessionQueue];
    }

    if (![session.outputs containsObject:_videoOutput]) {
        if ([session canAddOutput:_videoOutput]) {
            [session addOutput:_videoOutput];
            _videoOutputAdded = YES;
        } else {
            if (newError == nil) {
                newError = [VideoRecorder createError:@"Cannot add videoOutput inside the session"];
            }
        }
    }
    else {
        _videoOutputAdded = YES;
    }
}

_audioOutputAdded = NO;
if (self.audioConfiguration.enabled) {
    if (_audioOutput == nil) {
        _audioOutput = [[AVCaptureAudioDataOutput alloc] init];
        [_audioOutput setSampleBufferDelegate:self queue:_sessionQueue];
    }

    if (![session.outputs containsObject:_audioOutput]) {
        if ([session canAddOutput:_audioOutput]) {
            [session addOutput:_audioOutput];
            _audioOutputAdded = YES;
        } else {
            if (newError == nil) {
                newError = [VideoRecorder createError:@"Cannot add audioOutput inside the sesssion"];
            }
        }
    } else {
        _audioOutputAdded = YES;
    }
}

如何调整与此AVCaptureConnection相关联的AVCaptureSession的音量,因为它似乎只适用于mac?

录制时如何调整录制音量?

如果有其他方法可以实现,请告诉我。

0 个答案:

没有答案