//函数作用:将解码出来的YUV数据保存成JPG图像
//out_file_name -- JPEG图像保存路径
//w, h -- 图像宽高
//linesize -- 图像的Y分量宽度(一般4字节对齐)
//Y, U, V -- 指向图像Y,U,V三个平面的指针
//
int EncodeAndSaveJPEG(const char* out_file_name, int w, int h, int linesize, uint8_t * Y, uint8_t * U, uint8_t * V)
{
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;
//av_register_all();
#if 0
//Method 1
pFormatCtx = avformat_alloc_context();
//Guess format
fmt = av_guess_format("mjpeg", NULL, NULL);
pFormatCtx->oformat = fmt;
//Output URL
if (avio_open(&pFormatCtx->pb, out_file_name, AVIO_FLAG_READ_WRITE) < 0){
fprintf(stderr, "Couldn't open output file.\n");
return -
用FFmpeg保存JPEG图片
最新推荐文章于 2024-05-30 20:46:46 发布