我一直在寻找Stack,我发现了类似的问题,但没有一个对我有用.我是Swift 3.0的新手.基本上我要做的是使用AVFoundation录制视频.到目前为止,我已设法捕获静止图像,这是我到目前为止的代码
func beginSession() {
do {
let deviceInput = try AVCaptureDeviceInput(device: captureDevice) as AVCaptureDeviceInput
if captureSession.inputs.isEmpty {
self.captureSession.addInput(deviceInput)
}
stillImageOutput.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG]
if captureSession.canAddOutput(stillImageOutput) {
captureSession.addOutput(stillImageOutput)
}
}
catch {
print("error: \(error.localizedDescription)")
}
guard let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) else {
print("no preview layer")
return
}
self.view.layer.addSublayer(previewLayer)
previewLayer.frame = self.view.layer.frame
captureSession.startRunning()
// Subviews
self.view.addSubview(imgOverlay)
self.view.addSubview(blur)
self.view.addSubview(label)
self.view.addSubview(Flip)
self.view.addSubview(btnCapture)
}
Run Code Online (Sandbox Code Playgroud)
和
// SAVE PHOTO
func saveToCamera() {
if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) {
stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (CMSampleBuffer, Error) …
Run Code Online (Sandbox Code Playgroud) 有没有办法将 UIKit 坐标(0,0 左上)转换为 Quartz/CoreImage(0,0 左下)?在这里找不到任何与此相关的快速信息。