远方是什么样子 2022-04-25 20:32 采纳率: 0%
浏览 136

ffmpeg android版开发报错:avformat_open_input打开摄像头返回值-2

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;
}

请问大家怎么办

  • 写回答

1条回答 默认 最新

  • 「已注销」 2022-04-25 21:21
    关注

    摄影头是内置还是外置的

    评论

报告相同问题?

问题事件

  • 创建了问题 4月25日

悬赏问题

  • ¥15 ssh登录页面的问题
  • ¥60 渗透一个指定银行app,拿到客户信息,需要什么级别
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问
  • ¥15 用MATLAB汇总拟合图