This question already has answers here :
The answer is movieFileOutput.movieFragmentInterval = kCMTimeInvalid;
Apparently it is set to 10 default, and anything after, audio won't record. Referenced from AVCaptureSession audio doesn't work for long videos
Was easy to find answer once I figured out time was involved with the problem
automaticallyConfiguresApplicationAudioSession, Note that the audio session's original state is not restored after capture finishes. Recording may fail if the audio session's settings are incompatible with the Its surprisingly hard to find good working examples of recording video with AVCaptureSession. This is the results of us coming up with a nice and simple implementation which works and can be expanded on as required.
Swift 4.2
movieFileOutput.movieFragmentInterval = CMTime.invalid
AVAudioSessionErrorCodeCannotStartRecording when recording , Previously the app has been able to record audio for transmition while in the Recording restart in background after interrupt does not work on iOS 13.0 beta, Using an audio recorder, you can: Record until the user stops the recording. Record for a specified duration. Pause and resume a recording. Obtain input audio-level data that you can use to provide level metering. In iOS, the audio being recorded comes from the device connected by the user—built-in microphone or headset microphone, for example.
videoFileOutput.movieFragmentInterval = kCMTimeInvalid
solved this for me.
However, I accidentally set the movieFragmentInterval after calling startRecordingToOutputFileURL. An agonising hour later I realised my mistake. For newbies like me - note THIS OBVIOUS SEQUENCE.
videoFileOutput.movieFragmentInterval = kCMTimeInvalid
videoFileOutput.startRecordingToOutputFileURL(filePath, recordingDelegate: recordingDelegate)
iOS, This tutorial for real time Capture Video with Audio Using Capture session in no need all. we used AVCaptureSession, AVCaptureVideoPreviewLayer, extension ViewController : AVCaptureFileOutputRecordingDelegate {. The answer is movieFileOutput.movieFragmentInterval = kCMTimeInvalid; Apparently it is set to 10 default, and anything after, audio won't record. Referenced from AVCaptureSession audio doesn't work for long videos. Was easy to find answer once I figured out time was involved with the problem
Recording from the microphone with AVAudioRecorder, Make sure "Also create XIB file" is not selected and that "Swift" is chosen for your language, Recording audio in iOS uses two classes: AVAudioSession and If you’re having audio problems, the following suggestions might help. The tips are listed in order, so start with the first one, see if that helps, and then continue to the next one if it doesn’t.
Record Video With AVCaptureSession – iOS Developer, AVCaptureVideoPreviewLayer – shows the user what a camera is recording create video capture device"); } //ADD AUDIO INPUT NSLog(@"Adding audio Full photo resolution (not supported for video output) NSLog(@"Setting image Speakers - Select this option to capture sound produced by other applications. *Please note that Debut needs to be launched prior to the application that you are recording for this to work properly; Mouse Clicks - Select this option to record a sound when the mouse is clicked. *The sound is recorded even if no audio device is found in the system.
AVCaptureSession Class (AVFoundation), The AVCaptureSession object coordinates the recording of video or audio input Gets or sets a Boolean value that controls whether or not the session should An AVCaptureDevice object abstracts a physical capture device that provides input data (such as audio or video) to an AVCaptureSession object. There is one object for each input device, for example, two video inputs—one for the front-facing the camera, one for the back-facing camera—and one audio input for the microphone.
Comments I really don't see the need for sarcasm. You assign audioInput
yet never check error2
. Given that audioInput
is where you're having a problem isn't that a reasonable suggestion? No error messages ever show. However, I found a common denominator. Audio will record, but only if recording is 10 seconds or shorter. If it hits 11 seconds the audio doesn't record. thanks for the answer. but this does not make any sense. wow apple seriously? OMG I was like why am getting only 10 seconds audio This is works for me. Thanks. what is it do? Can you explain