iOS 8 iPad AVCaptureMovieFileOutput drops / loses / never gets audio track after 13 - 14 seconds of recording iOS 8 iPad AVCaptureMovieFileOutput drops / loses / never gets audio track after 13 - 14 seconds of recording ios ios

iOS 8 iPad AVCaptureMovieFileOutput drops / loses / never gets audio track after 13 - 14 seconds of recording


This will help you to fix it.

[movieOutput setMovieFragmentInterval:kCMTimeInvalid];

I think this is a bug. The documentation says the sample table is not written if the recording does not complete successfully. So it will automatically be written if it does complete successfully. But now it seems like it doesn't.

Any ideas?


I had this issue and the way to fix this in Swift 4 is the following:

  • Do not set movieFileOutput.maxRecordedDuration. There seems to be a bug with this where if you set this then if you are recording videos for longer than 12-13 seconds they will have no audio.

  • Instead use a timer to stop the recording and set movieFragmentInterval like this:

movieFileOutput.movieFragmentInterval = CMTime.invalid

Here is a whole block of code just to show you how I did it:

var seconds = 20var timer = Timer()var movieFileOutput = AVCaptureMovieFileOutput()func startRecording(){    movieFileOutput.movieFragmentInterval = CMTime.invalid    movieFileOutput.startRecording(to: URL(fileURLWithPath: getVideoFileLocation()), recordingDelegate: self)    startTimer()}func stopRecording(){    movieFileOutput.stopRecording()    timer.invalidate()}func startTimer(){    timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(updateTimer)), userInfo: nil, repeats: true)}@objc func updateTimer(){    seconds -= 1    if(seconds == 0){        stopRecording()    }}func getVideoFileLocation() -> String {    return NSTemporaryDirectory().appending("myrecording.mp4")}extension FTVideoReviewViewController : AVCaptureFileOutputRecordingDelegate{    public func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {        print("Finished recording: \(outputFileURL)")        // do stuff here when recording is finished    }}