FFmpeg RGB转H264
前言 下面代码是在我的上一篇博客: FFmpeg RGB转YUV 的代码的基础上修改而来的,创建了编码器并进行 H264 编码,进一步将 RGB 格式像素数据转换成 H264 格式像素数据,亲测有效。 <br /> 完整代码 #include <iostream> extern "C" { #include <libavformat/avformat.h> #include <libswscale/swscale.h> } #pragma comment(lib,"avformat.lib") #pragma comment(lib,"avcodec.lib") #pragma comment(lib,"avutil.lib") #pragma comment(lib,"swscale.lib") using namespace std; int main() { char infile[] = "dove_BGRA.rgb"; char outfile[] = "out.264"; // 源图像参数 int width = 640; int height = 360; int fps = 25; //1 打开RGB和H264文件 FILE *fpin = fopen(infile, "rb"); if (!fpin) { cout << infile << "open