2

我正在尝试使用AVFoundation Framework. 我遇到的问题是,当我在几帧之后停止录制时出现错误AVErrorNoDataCaptured = -11805,我可以清楚地看到帧被捕获为captureOutput:didDropSampleBuffer:fromConnection:

我的设置如下

[self.captureSession beginConfiguration]; //AVCaptureSession *captureSession;
[self.captureScreenInput setCropRect:rect]; //AVCaptureScreenInput *captureScreenInput
[self.captureScreenInput setCapturesMouseClicks:captureMouseClicks];
[self.captureScreenInput setScaleFactor:2.f/[[NSScreen mainScreen] backingScaleFactor]];
[self.captureScreenInput setMinFrameDuration:CMTimeMake(1,15)];
[self.captureScreenInput setRemovesDuplicateFrames:YES];
[_captureSession commitConfiguration];

.

-(void)captureOutput:(AVCaptureFileOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
    static int i = 0;
    NSLog(@"Frame: %d", ++i);
    CMTime recTime = [_captureMovieFileOutput recordedDuration];
    if(recTime.timescale > 0)
        NSLog(@"Time Value: %lld Seconds:: %lld ",recTime.value, recTime.value/recTime.timescale);
    NSLog(@"Size: %lld Kb",[_captureMovieFileOutput recordedFileSize]/1024);
} 

文档说

只要文件输出从给定连接接收到单个样本缓冲区(例如,单个视频帧或音频缓冲区),就会调用此方法。这使代表有机会在精确的样本边界开始和停止记录或更改输出文件。如果在此方法中调用,文件输出的 startRecordingToOutputFileURL:recordingDelegate: 和 resumeRecording 方法保证将接收到的样本缓冲区包含在新文件中,而对 stopRecording 和 pauseRecording 的调用保证包括当前样本中的所有样本现有文件中的缓冲区。

那么这里的问题是什么,为什么我不能拥有更少帧的视频。帧的输出日志如下

 Frame: 1
 Size: 0 Kb
 Frame: 2
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 3
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 4
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 5
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 6
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 7
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 8
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 9
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 10
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Frame: 11
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Time Value: 0 Seconds:: 0 
 Size: 0 Kb
 Not Recording
 Frame: 12
 Size: 0 Kb
 Frame: 13
 Size: 0 Kb
 Frame: 14
 Size: 0 Kb
 Frame: 15
 Size: 0 Kb
4

0 回答 0