iPhone: 5 seconds video capture

2019-07-19 17:34发布

I would like to write code so that when the user presses a button, the camera is launched and records 5 seconds of video. In other words I want to have video capture but with a time limit.

Is there something inside the UIImagePickerController or other parts of the framework that would allow doing this? Thank you.

1条回答
乱世女痞
2楼-- · 2019-07-19 18:03

There is nothing that allows you to directly do this. But you can very easily use UIImagePickerController's startVideoCapture to begin the capture and then call stopVideoCapture 5 seconds later, for example with [picker performSelector:@selector(stopVideoCapture) withObject:nil afterDelay:5].

Or you can do basically the same thing with AVFoundation, in particular AVCaptureMovieFileOutput's startRecordingToOutputFileURL:recordingDelegate: and stopRecording methods.

查看更多
登录 后发表回答