AVCapture appendSampleBuffer

后端 未结 2 1030
一向
一向 2021-02-01 10:46

I am going insane with this one - have looked everywhere and tried anything and everything I can thinks of.

Am making an iPhone app that uses AVFoundation - specifically

2条回答
  •  眼角桃花
    2021-02-01 11:28

    I do it by using CMSampleBufferCreateForImageBuffer() .

    OSStatus ret = 0;
    CMSampleBufferRef sample = NULL;
    CMVideoFormatDescriptionRef videoInfo = NULL;
    CMSampleTimingInfo timingInfo = kCMTimingInfoInvalid;
    timingInfo.presentationTimeStamp = pts;
    timingInfo.duration = duration;
    
    ret = CMVideoFormatDescriptionCreateForImageBuffer(NULL, pixel, &videoInfo);
    if (ret != 0) {
        NSLog(@"CMVideoFormatDescriptionCreateForImageBuffer failed! %d", (int)ret);
        goto done;
    }
    ret = CMSampleBufferCreateForImageBuffer(kCFAllocatorDefault, pixel, true, NULL, NULL,
                                             videoInfo, &timingInfo, &sample);
    if (ret != 0) {
        NSLog(@"CMSampleBufferCreateForImageBuffer failed! %d", (int)ret);
        goto done;
    }
    

提交回复
热议问题