ffmpeg4.0以上版本找不到img_convert,查了一下原因,才知道换成了sws_scale,
所以原来的
img_convert((AVPicture *)pFrameRGB, PIX_FMT_BGR24, (AVPicture*)pFrame,pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
应该改成:
struct SwsContext *img_convert_ctx; if (img_convert_ctx == NULL) { img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL); if (img_convert_ctx == NULL) { fprintf(stderr, "Cannot initialize the conversion context/n"); exit(1); } } sws_scale(pthis->img_convert_ctx, pthis->pFrame->data, pthis->pFrame->linesize, 0, pthis->pCodecCtx->height, pthis->pFrameRGB->data, pthis->pFrameRGB->linesize);