AVInputFormat *ifmt;
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVDictionary *options=nullptr;
AVPacket *packet;
AVFrame *pFrame,*pFrameYUV;
int videoindex;
int i,ret,got_picture;
/*1. FFMPEG初始化*/
av_register_all();
avcodec_register_all();
avdevice_register_all(); //注册多媒体设备交互的类库
avfilter_register_all();
/*2. 查找用于输入的设备*/
ifmt=av_find_input_format("video4linux2");
const char* url = "/dev/video0";
pFormatCtx=avformat_alloc_context();
av_dict_set(&options,"video_size","480x640"/*size*/,0); //设置摄像头输出的分辨率
av_dict_set(&options,"framerate","30",0); //设置摄像头帧率. 每秒为单位,这里设置每秒30帧.
av_dict_set(&options, "input_format", "mjpeg", 0);
//一般帧率不用设置,默认为最高,帧率和输出的图像尺寸有关系
int success = avformat_open_input(&pFormatCtx,url,ifmt,&options);
if(success!=0)
{
log_Display(tr("输入设备打开失败: %1\n").arg(video));
char buf[] = "";
av_strerror(success, buf, 1024);
qDebug()<< "输入设备打开失败,返回值:" + QString::number(success) + " " + buf;
return -1;
}
请问大家怎么办