【问题标题】:Conversion from Iphone Core Surface RGB Frame into ffmepg AVFarme从 Iphone Core Surface RGB Frame 转换为 ffmpeg AVFrame
【发布时间】:2015-03-10 15:29:10
【问题描述】:

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

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

这是我的代码:

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);   

请帮帮我。

谢谢,

拉古

【问题讨论】:

  • 你知道Surface 是一个私有API,因此这个应用程序永远不会被商店接受?
  • 如果我没记错的话,所有人都在使用核心表面,使用带有 dlopen() 和 dlsym() 的动态调用,而苹果似乎正在接受那些家伙的应用程序。

标签: iphone ffmpeg


【解决方案1】:

这样就可以解决问题了:

pFrameRGB->linesize[0] = pCodecCtx->width * 4; // linesize includes total bytes for the line (ARGB)

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

【讨论】:

  • 我认为有证据表明人们使用核心表面使用 dlopen() 和 dlsym() 来隐藏苹果静态 api 捕手
  • 是的,我使用 width*4 解决了这个问题,还必须将 RGB24 更改为 RGB32。现在它工作正常
  • 您知道从相机获取原始流的任何有效方法吗?
  • 不,我不知道任何有效的方法。向我们通报任何进展。
猜你喜欢
  • 2015-05-29
  • 2010-11-06
  • 1970-01-01
  • 1970-01-01
  • 2013-02-21
  • 2020-12-18
  • 2018-04-13
  • 2021-11-25
  • 1970-01-01
相关资源
最近更新 更多