如何使用Image Picker Controller Swift镜像翻转视频结果?

问题描述

我想使用带图像选择器控制器的前置摄像头来录制视频,并使结果的视频与录制时看到的视频相匹配。

例如。如果在录制过程中我的头向右倾斜。完成并观看视频预览后,我的头向左倾斜。如何设置它,使预览和最终视频输出都是我在录制时看到的? (头向右倾斜。)

func startRecording() {
    
    if (UIImagePickerController.isSourceTypeAvailable(.camera)) {
        if UIImagePickerController.availableCaptureModes(for: .rear) != nil {
            
            imagePicker.sourceType = .camera
            imagePicker.cameraDevice = .front
            imagePicker.mediaTypes = [kUTTypeMovie as String]
            imagePicker.allowsEditing = false
            imagePicker.delegate = self
           
            present(imagePicker,animated: true,completion: {})

        } else {
            postAlert("Rear camera doesn't exist",message: "Application cannot access the camera.")
        }
    } else {
        postAlert("Camera inaccessible",message: "Application cannot access the camera.")
    }
}


    func imagePickerController(_ picker: UIImagePickerController,didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

        print("Video has been created")
        
        // Flip video here?
        
        if let pickedVideo:URL = (info[UIImagePickerController.InfoKey(rawValue: UIImagePickerController.InfoKey.mediaURL.rawValue)] as? URL) {
            
            // Save the video to the app directory so we can play it later
            guard let path = self.createFolder() else {
                return
            }

            let videoData = try? Data(contentsOf: pickedVideo)
            try! videoData?.write(to: path,options: [])
            
        }

        imagePicker.dismiss(animated: true,completion: {
            // Do something when the user saves a video
        })
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...