如何使用 ffmpeg 的 swscale 从 NV12 转换为 RGB32?
How can I use ffmpeg's swscale to convert from NV12 to RGB32?
假设我在内存中有一个NV12帧作为字节数组。我知道:
- 其宽度和高度
- 它的Stride(一条线的总宽度,包括padding),这是相同的Y和UV组件根据NV12规范
- 我知道Y从哪里开始,U从Y + (Stride * Height)开始,V从U + 1(与U交叉)开始。
现在我写的是:
SwsContext* context = sws_getContext(frameWidth, frameHeight, AV_PIX_FMT_NV12, frameWidth, frameHeight, AV_PIX_FMT_RGB32, 0, nullptr, nullptr, nullptr);
sws_scale(context,
我不知道sws_scale的参数应该是什么
- srcSlice:指向字节数组的指针?显然应该是a一个指针指向另一个指针,但我得到的只是一个单维空间
- srcStride:显然需要一个跨步数组,但是我只有一个跨步用于整个文件。我应该传递一个数组吗一个元素?
- srcSliceY:我猜第一个字节的偏移量?那么应该是0。
- srcSliceH:帧高度,我猜
- dst:再一次,指针指向指针,但我的目标输出实际上只是另一个字节数组…
- dstStride:宽度* 4我猜?
感谢您的帮助。
/// uint8_t * Y;
/// uint8_t * out;
// 2 planes for NV12: Y and interleaved UV
uint8_t * data[2] = {Y, Y + Stride * Height};
// Strides for Y and UV
// U and V have Stride/2 bytes per line;
// Thus, we have 2 * Stride/2 bytes per line in UV plane
int linesize[2] = {Stride, Stride};
uint8_t * outData[1] = {out}; // RGB have one plane
int outLinesize[1] = {frameWidth*4}; // RGB32 Stride
sws_scale(context, data, linesize, 0, Height, outData, outLinesize);
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中使用nlohmann从类到json的转换
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 复制列表初始化的隐式转换的等级是多少
- 正在将指针转换为范围
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 是否可以从int转换为enum类类型
- 了解 GLM- openGL 中的相机转换
- 如何使用 ffmpeg 的 swscale 从 NV12 转换为 RGB32?