dan*_*anh 17 iphone avfoundation ios avcam
Apple文档似乎表明,在将视频录制到文件时,应用程序可以动态更改URL,没有任何问题.但我看到了一个问题.当我尝试这个时,录制代表被调用错误...
这项行动无法完成.(OSStatus错误-12780.)信息字典是:{AVErrorRecordingSuccessfullyFinishedKey = 0; }
("can not"中的时髦单引号来自日志记录[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];
}
Run Code Online (Sandbox Code Playgroud)
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];
}
Run Code Online (Sandbox Code Playgroud)
注意:[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];
}
}
Run Code Online (Sandbox Code Playgroud)
当这个运行时,file-0被写入,然后我们在将url更改为file-5之后立即看到错误-12780,文件-10被写入,然后是错误,然后好的,依此类推.
看来,动态更改URL不起作用,但它会停止写入,允许下一个URL更改工作.
任何帮助将非常感激.
谢谢大家,对此进行了审核和好评.这是来自Apple DTS的一句话......
我与我们的AV基金会工程师进行了交谈,这肯定是一个错误,因为这种方法没有按照文档所说的那样做("在进行另一次录制时,你不需要在调用此方法之前调用stopRecording.").请使用Apple Bug Reporter(http://developer.apple.com/bugreporter/)提交错误报告,以便团队进行调查.确保并在报告中包含您的最小项目.
我已将此作为错误11632087向Apple提交
归档时间: |
|
查看次数: |
3092 次 |
最近记录: |