Conversion from Iphone Core Surface RGB Frame into ffmepg AVFarme

Posted by Sridhar on Stack Overflow See other posts from Stack Overflow or by Sridhar
Published on 2010-03-07T13:33:08Z Indexed on 2010/03/08 5:06 UTC
Read the original article Hit count: 583

Filed under:
|
|
|

Hello,

I am trying to convert Core Surface RGB frame buffer(Iphone) to ffmpeg Avfarme to encode into a movie file. But I am not getting the correct video output (video showing colors dazzling not the correct picture)

I guess there is something wrong with converting from core surface frame buffer into AVFrame.

Here is my 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);   

Please help me out.

Thanks,

Raghu

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core