GPT答: |
7i24.cn
|
么?
在新版本的FFmpeg中,可以使用av_image_alloc()函数来分配内存空间,并使用av_image_fill_arrays()函数来填充图像数据。
具体代码如下:
uint8_t *out_buffer;
int out_buffer_size;
// 分配内存空间
out_buffer_size = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1);
out_buffer = (uint8_t *)av_malloc(out_buffer_size);
// 填充图像数据
AVFrame *pFrameYUV = av_frame_alloc();
av_image_fill_arrays(pFrameYUV->data, pFrameYUV->linesize, out_buffer,
AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1);
|