How can I record 4k 60 FPS to internal storage in Swift? Like other external apps such as Blackmagic cam

53 Views Asked by At

I run into the following exception when I attempt to record 4k or 1080p footage at 60 FPS in Pro Res format

AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] Capturing 1080p60 with ProRes codec on this device is supported only on external storage device.'

This should be possible to do as other apps like Blackmagic cam (https://www.blackmagicdesign.com/ca/products/blackmagiccamera) allows this to be done.

Code snippets below for reference:

do {
    try self.videoDeviceInput.device.lockForConfiguration()
    self.videoDeviceInput.device.activeFormat = self.videoDeviceInput.device.findFormat()!
    self.videoDeviceInput.device.activeColorSpace = .appleLog
    let frameRate = CMTimeMake(value: 1, timescale: 60)
    self.videoDeviceInput.device.activeVideoMaxFrameDuration = frameRate
    self.videoDeviceInput.device.activeVideoMinFrameDuration = frameRate

    self.videoDeviceInput.device.unlockForConfiguration()
} catch {
    print("Could not lock device for configuration: \(error)")
}
// Start recording video to a temporary file.
let outputFileName = NSUUID().uuidString
let outputFilePath = (NSTemporaryDirectory() as NSString).appendingPathComponent((outputFileName as NSString).appendingPathExtension("mov")!)
movieFileOutput.startRecording(to: URL(fileURLWithPath: outputFilePath), recordingDelegate: self)

I have set all the correct activeFormat values and activeColorspace to allow for this.

0

There are 0 best solutions below