我正在尝试AV_PIX_FMT_YUV420P
使用 ffmpeglibavformat
和将 YUV420P 图像()转换为 JPEG libavcodec
。到目前为止,这是我的代码:
AVFormatContext* pFormatCtx;
AVOutputFormat* fmt;
AVStream* video_st;
AVCodecContext* pCodecCtx;
AVCodec* pCodec;
uint8_t* picture_buf;
AVFrame* picture;
AVPacket pkt;
int y_size;
int got_picture=0;
int size;
int ret=0;
FILE *in_file = NULL; //YUV source
int in_w = 720, in_h = 576; //YUV's width and height
const char* out_file = "encoded_pic.jpg"; //Output file
in_file = fopen(argv[1], "rb");
av_register_all();
pFormatCtx = avformat_alloc_context();
fmt = NULL;
fmt = av_guess_format("mjpeg", NULL, NULL);
pFormatCtx->oformat = fmt;
//Output URL …
Run Code Online (Sandbox Code Playgroud)