ffmpeg 解码格式转换

简单的记录下格式转换的关键操作

int numBytes = avpicture_get_size(AV_PIX_FMT_RGB32, videoWidth, videoHeight);
uint8_t* out_buffer = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
avpicture_fill(AVPicture *)pAVFrameRGB32, out_buffer, AV_PIX_RGB32, videoWidth, videoHeight);
pSwsContext = sws_getContext(videoWidth, videoHeight, AV_PIX_FMT_YUV420, videoWidth,
                    videoHeight, AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);


/// 转换的代码
sws_scale(pSwsContext, (const uint8_t *const *)tmp_frame->data, tmp_frame->linesize, 
                    0, videoHeight, pAVFrameRGB32->data, pAVFrameRGB32->linesize);

 

你可能感兴趣的:(ffmpeg,ffmpeg)