xcode 暂停视频录制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14748031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:44:05  来源:igfitidea点击:

Pause video recording

iosxcodevideo-recording

提问by kroumvud

I'm trying to create an application where the user can record video from a camera. One of the features of this application must be a pause in file recording.

我正在尝试创建一个应用程序,用户可以在其中录制来自相机的视频。此应用程序的功能之一必须是文件录制的暂停。

For example: The user starts recording by pressing the "Start" button. After some time user presses the "Pause" button and video recording is paused. Then user presses the "Resume" button and video continues recording in the same file.

例如:用户通过按下“开始”按钮开始录制。一段时间后,用户按下“暂停”按钮,视频录制将暂停。然后用户按下“恢复”按钮,视频将继续录制在同一文件中。

Can anybody help me?

有谁能够帮助我?

采纳答案by Sten

Set up an AVCaptureSession and a AVAssetWriter then you can switch the recording on an off with the boolean "isRecording".

设置一个 AVCaptureSession 和一个 AVAssetWriter,然后您可以使用布尔值“isRecording”打开或关闭录音。

 BOOL isRecording;

-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
     if(videoWriterInput.readyForMoreMediaData && isRecording) [videoWriterInput appendSampleBuffer:sampleBuffer];
}