小编ala*_*sin的帖子

如何使用 ffmpeg 的库将 YUV420P 图像转换为 JPEG?

我正在尝试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)

jpeg yuv libavcodec libavformat

2
推荐指数
1
解决办法
5024
查看次数

标签 统计

jpeg ×1

libavcodec ×1

libavformat ×1

yuv ×1