我一直在尝试将 TrueDepth 数据编写为快速电影。我已经检查了来自https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/streaming_depth_data_from_the_truedepth_camera的示例 我知道可以使用AVCaptureMovieFileOutput()输出快速电影,但我不知道如何实现这一点。我一直在尝试做一些简单的事情,例如将前置摄像头的捕获会话保存到快速时间。任何帮助将不胜感激。这是我到目前为止所拥有的:
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var previewView: UIView!
var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
var videoCaptureDevice: AVCaptureDevice?
var input: AnyObject?
var movieOutput = AVCaptureMovieFileOutput()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
videoCaptureDevice = AVCaptureDevice.default(.builtInTrueDepthCamera,
for: .video, position: .front)
do {
input = try AVCaptureDeviceInput(device: videoCaptureDevice!)
} catch {
print("video device error")
}
captureSession = AVCaptureSession()
captureSession?.addInput(input as! AVCaptureInput)
captureSession?.addOutput(movieOutput)
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!)
videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
videoPreviewLayer?.frame = previewView.layer.bounds
previewView.layer.addSublayer(videoPreviewLayer!)
captureSession?.startRunning()
}