首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Iphone Core Surface RGB Frame到ffmepg AVFarme的转换

Iphone Core Surface RGB Frame到ffmepg AVFarme的转换
EN

Stack Overflow用户
提问于 2010-03-07 21:33:08
回答 1查看 818关注 0票数 2

我正在尝试将Core Surface RGB帧缓冲(Iphone)转换为ffmpeg Avfarme,以便编码为电影文件。但是我没有得到正确的视频输出(视频显示的颜色令人眼花缭乱,而不是正确的图片)

我猜从核心图面帧缓冲区转换为AVFrame可能有问题。

下面是我的代码:

代码语言:javascript
复制
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);   

请帮帮我。

谢谢,

拉古

EN

回答 1

Stack Overflow用户

发布于 2010-03-08 13:00:29

这将解决问题:

代码语言:javascript
复制
pFrameRGB->linesize[0] = pCodecCtx->width * 4; // linesize includes total bytes for the line (ARGB)

不要浪费时间,你不应该像St3fan建议的那样使用Surface。应用程序将被拒绝。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2396407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档