Я пытаюсь создать CMSampleBuffer Ref из данных и пытаюсь передать его в AVAssetWriter. Но автор ресурсов не может создать фильм на основе данных. Ниже приведен код для создания CMSampleBufferRef.
CVImageBufferRef cvimgRef = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(cvimgRef,0);
uint8_t *buf=(uint8_t *)CVPixelBufferGetBaseAddress(cvimgRef);
int width = 480;
int height = 360;
int bitmapBytesPerRow = width*4;
int bitmapByteCount = bitmapBytesPerRow*height;
CVPixelBufferRef pixelBufRef = NULL;
CMSampleBufferRef newSampleBuffer = NULL;
CMSampleTimingInfo timimgInfo = kCMTimingInfoInvalid;
CMSampleBufferGetSampleTimingInfo(sampleBuffer, 0, &timimgInfo);
OSStatus result = 0;
OSType pixFmt = CVPixelBufferGetPixelFormatType(cvimgRef);
CVPixelBufferCreateWithBytes(kCFAllocatorDefault, width, height, pixFmt, buf, bitmapBytesPerRow, NULL, NULL, NULL, &pixelBufRef);
CMVideoFormatDescriptionRef videoInfo = NULL;
result = CMVideoFormatDescriptionCreateForImageBuffer(NULL, pixelBufRef, &videoInfo);
CMSampleBufferCreateForImageBuffer(kCFAllocatorDefault, pixelBufRef, true, NULL, NULL, videoInfo, &timimgInfo, &newSampleBuffer);
Создание фильма отлично работает, когда мы используем исходный CMSampleBufferRef, полученный из метода обратного вызова вывода данных AVFoundation.
Но то же самое не удается, когда я пытаюсь создать фильм с использованием настраиваемого CMSampleBufferRef. Модуль записи активов выдает следующую ошибку:
The operation couldn’t be completed. (AVFoundationErrorDomain error -11800.)
Помогите мне решить эту проблему.