AVFoundation Adjust video recording volume
I am working on an application that has a video recording and the user can adjust the volume in it. I did it using AVFoundation. I initialized AVCaptureSession
and added, AVCaptureAudioDataOutput
and AVCaptureVideoDataOutput
both audio and video output. I am attaching a code snippet here as well.
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;
}
}
How do I adjust the volume AVCaptureConnection
that is related to this AVCaptureSession
because it seems like it's only available for mac?
How do I adjust the recording volume while recording?
Please let me know if there is another way to implement this.
source to share
No one has answered this question yet
Check out similar questions: