Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to save TrueDepth data while recording video on iOS?

I am looking for a way to save the depth information (for each frame) to a file while recording a video using the TrueDepth camera. I have found solutions for saving the depth data while taking photos, but not with video.

I currently have code for recording video and saving it to a file and capturing the depth data simultaneously. However, I don't know how to save the depth data. Basically I use AVCaptureSession and AVCaptureMovieFileOutput to save the recorded video. I found that the depth data is given by AVCaptureDepthDataOutput, but how can I save that to a file?

The main parts of the code:

let captureSession = AVCaptureSession()
let sessionOutput = AVCapturePhotoOutput()
let movieOutput = AVCaptureMovieFileOutput()
let depthDataOutput = AVCaptureDepthDataOutput()

if let device = AVCaptureDevice.default(.builtInTrueDepthCamera,
                                 for: .video, position: .front) {
let input = try AVCaptureDeviceInput(device: device )

  if captureSession.canAddInput(input){
    captureSession.sessionPreset = AVCaptureSession.Preset.photo
    captureSession.addInput(input)
    if captureSession.canAddOutput(sessionOutput){   
      captureSession.addOutput(sessionOutput)
      // Code for adding previewing the video
    }
  }

  if captureSession.canAddOutput(depthDataOutput){
    captureSession.addOutput(depthDataOutput)
  }
  if let connection = depthDataOutput.connection(with: .depthData) {
    connection.isEnabled = true
    depthDataOutput.isFilteringEnabled = false
    print("Depth data working")
  } else {
    print("No AVCaptureConnection")
  }

  // Capture the video to a file
  captureSession.addOutput(movieOutput)
  captureSession.startRunning()

  // ...
  // How to store the depth data from AVCaptureDepthDataOutput ?
}

Any ideas?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!