CMSampleBufferCreate

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;

}

你可能感兴趣的:(CMSampleBufferCreate)