相关疑难解决方法(0)

连续调用startRecordingToOutputFileURL:

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] …
Run Code Online (Sandbox Code Playgroud)

iphone avfoundation ios avcam

17
推荐指数
1
解决办法
3092
查看次数

AVFoundation 没有长视频的音轨

使用AVFoundation的方法录制视频时- (void)startRecordingToOutputFileURL:(NSURL*)outputFileURL recordingDelegate:(id<AVCaptureFileOutputRecordingDelegate>)delegate;,如果视频持续时间超过12秒,则输出文件中没有音轨。如果视频时长小于 12 秒,则一切正常...

接收输出文件 URL 的委托是:

- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error
{   
    NSLog(@"AUDIO %@", [[AVAsset assetWithURL:outputFileURL] tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]); //App crashes here...

    NSLog(@"VIDEO %@", [[AVAsset assetWithURL:outputFileURL] tracksWithMediaType:AVMediaTypeVideo]);
}
Run Code Online (Sandbox Code Playgroud)

我的应用因长度超过 12 秒的视频而崩溃,并出现以下错误:*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'

iphone avfoundation ios

2
推荐指数
1
解决办法
1137
查看次数

标签 统计

avfoundation ×2

ios ×2

iphone ×2

avcam ×1