Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS record video first frame is black

I'm made a record video app, but the first frame always be black.

I use:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 

and assetWriter to write sample buffer.

I found that the first sample buffer is mediaType:'soun', does it is the problem.

How should I do

like image 809
Wayn Liu Avatar asked Jul 26 '13 09:07

Wayn Liu


1 Answers

I had the same problem. And I think first sample buffer being "sound" should be the problem. What I tried to do is to ignore the first sample buffer if it's sound. Wait until the first "video" sample buffer comes in and then do the AVAssetWriter startWriting thing. I solved my problem by doing this.

like image 85
ethanchli Avatar answered Oct 21 '22 04:10

ethanchli