AVCaptureSession Record Video With Audio
Add below code between beginConfiguration()
and commitConfiguration()
// Add audio device to the recording
let audioDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
do {
let audioInput = try AVCaptureDeviceInput(device: audioDevice)
self.captureSession.addInput(audioInput)
} catch {
print("Unable to add audio device to the recording.")
}
You have not included the audio device:
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureDeviceInput * audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:nil];
[session addInput:audioInput]
between beginConfiguration
and commitConfiguration
. It'll work!!!