OC音视频

CMSampleBufferCreate

2018-04-17  本文已影响2人  FBLog

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;

}

上一篇 下一篇

猜你喜欢

热点阅读