gpt4 book ai didi

iphone - AVCaptureSession 暂停和恢复记录

转载 作者:可可西里 更新时间:2023-11-01 05:41:42 36 4
gpt4 key购买 nike

我正在使用 AVCaptureSession 为 iOS 5.0 制作电影应用程序。我让用户能够开始-暂停-开始-停止录制电影

我定义的三个按钮是

  • 开始录制

  • 停止录制

  • 暂停录制

我能够成功开始和停止录制。我无法做的是暂停录音,然后再次恢复。我在堆栈溢出上查看了这个问题/答案,但我不知道他们是如何暂停和恢复视频的?我确实在这里找到了其他一些帖子,但它们都没有任何示例代码可供我试用。如果 AVAssetWrtier 是可行的方法,您如何将它与 AVCaptureSession 一起使用?

ios - Pause video recording

Pause & resume video capture for same file with AVFoundation in iOS

这是我的三个按钮的代码

        -(IBAction) makeMovieNow
{
NSLog(@"makeMovieNow ...");

[session startRunning];
[movieFileOutput startRecordingToOutputFileURL:movieURL recordingDelegate:self];

}

-(IBAction) makeMovieStop
{
NSLog(@"makeMovieStop ...");

//stop recording
[session stopRunning];
}

-(IBAction) makeMoviePause
{
NSLog(@"makeMoviePause ...");

//pause video??? How?

}

//********** DID FINISH RECORDING TO OUTPUT FILE AT URL **********
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{

NSLog(@"didFinishRecordingToOutputFileAtURL - enter");

BOOL RecordedSuccessfully = YES;
if ([error code] != noErr)
{
NSLog(@"ERROR RECODING MOVIE!!! - enter");

// A problem occurred: Find out if the recording was successful.
id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey];
if (value)
{
RecordedSuccessfully = [value boolValue];
}
}
if (RecordedSuccessfully)
{
//----- RECORDED SUCESSFULLY -----
NSLog(@"didFinishRecordingToOutputFileAtURL - success");

UISaveVideoAtPathToSavedPhotosAlbum(videoPath2, self, nil, nil);

}
}

最佳答案

http://www.gdcl.co.uk/2013/02/20/iPhone-Pause.html 处有一个示例 iPhone正是这样做的。它使用数据输出而不是电影文件输出,以便将数据传递到应用程序。然后,如果启用了录制,应用程序会将示例传递给 AVAssetWriter,并且在暂停/恢复后,时间戳会进行调整以消除暂停。

G

关于iphone - AVCaptureSession 暂停和恢复记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15097320/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com