小编Ada*_*ard的帖子

使用AVFoundation捕获视频

我一直在寻找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)

media avfoundation ios swift

23
推荐指数
2
解决办法
2万
查看次数

将 UIKit 坐标转换为 Quartz/CoreImage (Swift)

有没有办法将 UIKit 坐标(0,0 左上)转换为 Quartz/CoreImage(0,0 左下)?在这里找不到任何与此相关的快速信息。

core-image coordinates ios swift quartz

3
推荐指数
1
解决办法
2253
查看次数

标签 统计

ios ×2

swift ×2

avfoundation ×1

coordinates ×1

core-image ×1

media ×1

quartz ×1