gpt4 book ai didi

iphone - 连续调用 startRecordingToOutputFileURL :

转载 作者:IT王子 更新时间:2023-10-29 08:16:18 26 4
gpt4 key购买 nike

The Apple docs似乎表明在将视频录制到文件时,该应用程序可以毫无问题地即时更改 URL。但我看到了一个问题。当我尝试这样做时,记录委托(delegate)被调用并出现错误...

The operation couldn’t be completed. (OSStatus error -12780.) Info dictionary is: { AVErrorRecordingSuccessfullyFinishedKey = 0; }

(“无法”中的时髦单引号来自日志记录 [error localizedDescription])

这是代码,基本上是对 WWDC10 AVCam 示例的调整:

1) 开始录制。启动计时器以每隔几秒更改一次输出 URL

- (void) startRecording
{
// start the chunk timer
self.chunkTimer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(chunkTimerFired:)
userInfo:nil
repeats:YES];

AVCaptureConnection *videoConnection = [AVCamCaptureManager connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self movieFileOutput] connections]];
if ([videoConnection isVideoOrientationSupported]) {
[videoConnection setVideoOrientation:[self orientation]];
}

if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[self setBackgroundRecordingID:[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]];
}

NSURL *fileUrl = [[ChunkManager sharedInstance] nextURL];
NSLog(@"now recording to %@", [fileUrl absoluteString]);
[[self movieFileOutput] startRecordingToOutputFileURL:fileUrl recordingDelegate:self];
}

2) 当计时器触发时,在不停止记录的情况下更改输出文件名

- (void)chunkTimerFired:(NSTimer *)aTimer {

if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[self setBackgroundRecordingID:[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]];
}

NSURL *nextUrl = [self nextURL];
NSLog(@"changing capture output to %@", [[nextUrl absoluteString] lastPathComponent]);

[[self movieFileOutput] startRecordingToOutputFileURL:nextUrl recordingDelegate:self];
}

注意:[self nextURL] 生成文件 url,如 file-0.mov、file-5.mov、file-10.mov 等。

3) 每次文件更改时都会调用它,并且每次其他调用都是错误...

- (void)              captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
id delegate = [self delegate];
if (error && [delegate respondsToSelector:@selector(someOtherError:)]) {
NSLog(@"got an error, tell delegate");
[delegate someOtherError:error];
}

if ([self backgroundRecordingID]) {
if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
}
[self setBackgroundRecordingID:0];
}

if ([delegate respondsToSelector:@selector(recordingFinished)]) {
[delegate recordingFinished];
}
}

运行时,file-0 被写入,然后我们在将 url 更改为 file-5 后立即看到错误 -12780,file-10 被写入,然后是错误,然后是正常的,等等。

看起来即时更改 URL 不起作用,但它会停止写入,从而允许下一个 URL 更改起作用。

最佳答案

谢谢大家的评论和好的想法。这是来自 Apple DTS 的词...

I spoke with our AV Foundation engineers, and it is definitely a bug in that this method is not doing what the documentation says it should ("You do not need to call stopRecording before calling this method while another recording is in progress."). Please file a bug report using the Apple Bug Reporter (http://developer.apple.com/bugreporter/) so the team can investigate. Make sure and include your minimal project in the report.

我已将此作为错误 11632087 提交给 Apple

关于iphone - 连续调用 startRecordingToOutputFileURL :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10858793/

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