Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift UIImagePickerController视频最大大小_Swift_Xcode_Uiimagepickercontroller - Fatal编程技术网

Swift UIImagePickerController视频最大大小

Swift UIImagePickerController视频最大大小,swift,xcode,uiimagepickercontroller,Swift,Xcode,Uiimagepickercontroller,我正在使用UIImagePickerController录制视频,我需要一个最大持续时间30秒的视频或最大大小40 MB的视频。默认情况下,我设置了它videoMaximumDuration,但我不知道如何限制视频的最大大小,有没有办法限制视频大小?请参考此库 我认为你不能限制视频大小,因为用户可以选择任何大小的视频。您可以在发送到服务器之前对其进行压缩。 let maxDuration:Float64 = 60 let videoDuration = asset!.duration let v

我正在使用UIImagePickerController录制视频,我需要一个最大持续时间30秒的视频或最大大小40 MB的视频。默认情况下,我设置了它videoMaximumDuration,但我不知道如何限制视频的最大大小,有没有办法限制视频大小?

请参考此库


我认为你不能限制视频大小,因为用户可以选择任何大小的视频。您可以在发送到服务器之前对其进行压缩。
let maxDuration:Float64 = 60
let videoDuration = asset!.duration
let videoDurationSeconds = CMTimeGetSeconds(videoDuration)

   if videoDurationSeconds > maxDuration {
       if UIVideoEditorController.canEditVideoAtPath(asset!.URL.path!) {
              let videoEditor = UIVideoEditorController()
              self.videoEditor.videoPath = asset!.URL.path!
              self.videoEditor.videoMaximumDuration = 60.0
              self.presentViewController(self.videoEditor, animated: true, completion: nil)

             }

         }


// MARK: - UIVideoEditorControllerDelegate

func videoEditorController(editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) { 

                 self.videoEditor.dismissViewControllerAnimated(true, completion: nil)
                            //Do whatever you wish with the trimmed video here
                        }