How to get raw frame data from AVFrame.data[] and AVFrame.linesize[] without specifying the pixel format?

谁都会走 提交于 2019-12-03 00:52:56

linesize[i] contains stride for the i-th plane.

To obtain the whole buffer, use the function from avcodec.h

/**
 * Copy pixel data from an AVPicture into a buffer, always assume a
 * linesize alignment of 1. */   
int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
                 int width, int height,
                 unsigned char *dest, int dest_size);

Use

int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);

to calculate the required buffer size.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!