AVCaptureMovieFileOutput - no active/enabled connections

前端 未结 4 1924
萌比男神i
萌比男神i 2021-02-13 10:43

I am trying to record video in my iPhone app using AVFoundation. But whenever I click the Record button app crashes with this message

-[AVCaptureMovieFile

4条回答
  •  别跟我提以往
    2021-02-13 11:29

    Because currently you don't have an active connection to record video to file.
    Check connection active status before recording to output file:

    AVCaptureConnection *c = [self.movieOutput connectionWithMediaType:AVMediaTypeVideo];
    if (c.active) {
      //connection is active
    } else {
      //connection is not active
      //try to change self.captureSession.sessionPreset,
      //or change videoDevice.activeFormat
    }
    

    If connection is not active, try to change captureSession.sessionPreset or videoDevice.activeFormat.
    Repeat until you have set a valid format (that means c.active == YES). Then you can record video to output file.

提交回复
热议问题