1

I want to record video using ARKit and SceneKit, but I can save footage from ARKit but can't save footage from SceneKit. My code that starts the recording is as follows:

    @IBAction func startRecording(sender: UIButton) {
    sender.backgroundColor = .red


    do {
        _ = try sceneView.startVideoRecording()
        
      guard let recorder = sceneView.recorder else { return }
      let captureSession = session

      guard let audioDevice = AVCaptureDevice.default(for: .audio) else { return }
      
      do {
        let captureInput = try AVCaptureDeviceInput(device: audioDevice)
        

        guard captureSession.canAddInput(captureInput) else { return }
     
        captureSession.addInput(captureInput)
        
      } catch {
        print("Can't create AVCaptureDeviceInput: \(error)")
        
      }
      guard captureSession.canAddRecorder(recorder) else { return }
      captureSession.addRecorder(recorder)
      captureSession.startRunning()
      self.captureSession = captureSession
        
    } catch {
        print("Something went wrong during video-recording preparation: \(error)")
        
    }
    
}

My code that ends the recording is as follows:

    @IBAction func stopRecording(sender: UIButton) {

    sender.backgroundColor = .white
        
    sceneView.finishVideoRecording { (recording) in
        print("Recoring Finished", recording.url)
        self.checkAuthorizationAndPresentActivityController(toShare: recording.url, using: self)
    }
    

}

The video link created as a result of my code running is:screen recording

I cannot record the video from the camera. How can I fix my problem with the recording?

huseyin
  • 63
  • 7
  • Just so I am clear -- you can save camera video when ARKit is running, but not when SceneKit is used as well? – wcochran Jan 11 '21 at 20:51
  • @wcochran What should I use for this? – huseyin Jan 11 '21 at 21:23
  • I was just trying to understand exactly what you question was. There is an open source library for capturing ARKit video + AR elements added via SpriteKit or SceneKit: https://github.com/AFathi/ARVideoKit – wcochran Jan 11 '21 at 21:27

0 Answers0