Ich versuche, Core Surface RGB Frame Buffer (Iphone) in ffmpeg Avfarme zu konvertieren und in eine Filmdatei zu kodieren. Aber ich bin nicht immer die richtige Video-Ausgang (Video zeigt Farben schillernd nicht das richtige Bild)
Ich vermute, dass etwas mit der Konvertierung von Core Surface Frame Buffer in AVFrame nicht stimmt.
Hier ist mein Code:
Surface *surface = [[Surface alloc]initWithCoreSurfaceBuffer:coreSurfaceBuffer];
[surface lock];
unsigned int height = surface.height;
unsigned int width = surface.width;
unsigned int alignmentedBytesPerRow = (width * 4);
if (!readblePixels) {
readblePixels = CGBitmapAllocateData(alignmentedBytesPerRow * height);
NSLog(@"alloced readablepixels");
}
unsigned int bytesPerRow = surface.bytesPerRow;
void *pixels = surface.baseAddress;
for (unsigned int j = 0; j < height; j++) {
memcpy(readblePixels + alignmentedBytesPerRow * j, pixels + bytesPerRow * j, bytesPerRow);
}
pFrameRGB->data[0] = readblePixels; // I guess here is what I am doing wrong.
pFrameRGB->data[1] = NULL;
pFrameRGB->data[2] = NULL;
pFrameRGB->data[3] = NULL;
pFrameRGB->linesize[0] = pCodecCtx->width;
pFrameRGB->linesize[1] = 0;
pFrameRGB->linesize[2] = 0;
pFrameRGB->linesize[3] = 0;
sws_scale (img_convert_ctx, pFrameRGB->data, pFrameRGB->linesize,
0, pCodecCtx->height,
pFrameYUV->data, pFrameYUV->linesize);
Bitte helfen Sie mir weiter.
Danke,
Raghu