0

我正在使用 AVFoundation 框架使用 AVCaptureSession 对视频进行编码。

视频和音频在 ios7 (iPAD) 中成功录制并保存到相机胶卷中,但在我的 ios 6 (iPOD TOUCH) 中没有

以下代码将示例缓冲区添加到音频和视频 AVAssetWriterInput。

   -(void) captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection
    {
        CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
        CGSize imageSize = CVImageBufferGetEncodedSize(imageBuffer);
        NSString *desc = [captureOutput description];
        NSLog(@"Desc : %@",desc);

        //  also in the 'mediaSpecific' dict of the sampleBuffer
        //  UIImage *image = [self imageFromSampleBuffer:sampleBuffer];

            if (CMSampleBufferDataIsReady(sampleBuffer) )
            {
                if (encoder._writer.status == AVAssetWriterStatusUnknown)
                {
                    CMTime startTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
                    BOOL didStart = [encoder._writer startWriting];
                    [encoder._writer startSessionAtSourceTime:startTime];
                }

                if(captureOutput == outputDevice)
                {
                    //To catch image Buffer
                    [encoder._writerInput appendSampleBuffer:sampleBuffer];
                    frameCount++;
                }

                if(captureOutput == audioOutput)
                {
                    //To catch audio buffer
                    [encoder.audioWriterInput appendSampleBuffer:sampleBuffer];
                }
            }
        NSLog( @"frame captured at %.fx%.f", imageSize.width, imageSize.height );
    }

我得出的结论是,在 iPOD 即 iOS 6 中捕获的大多数帧都被使用以下代码丢弃。

- (void)captureOutput:(AVCaptureOutput *)captureOutput didDropSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
    if(captureOutput==outputDevice)
    {
        CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
        CGSize imageSize = CVImageBufferGetEncodedSize(imageBuffer);
        NSLog( @"Discarded Frame at %.fx%.f", imageSize.width, imageSize.height );
    }
}

请帮助我,我被严重困在这里,无法继续前进。

建议我一些解决方案,或者至少建议您对这些情况的宝贵想法和假设。

提前谢谢你。

4

0 回答 0