尼尼帕 2023-09-21 11:43 采纳率: 0%
浏览 28
已结题

avformat_open_input(); 返回值为-5

mac中使用qt做的开发,这里有个问题想请求帮助,avformat_open_input(); 返回值为-5
***下面是我代码
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec pCodec;
AVDictionary
pOptions = NULL;
//设置编码格式
av_dict_set(&pOptions, "pixel_format", "uyvy422", 0);
//设置分辨率
av_dict_set(&pOptions,"video_size","3264x2448",0);

//设置帧率
av_dict_set(&pOptions,"framerate","30",0);

// 打开摄像头
pFormatCtx = avformat_alloc_context();
AVInputFormat *ifmt = av_find_input_format("avfoundation");

const char* indexs = devId.c_str();
iRet=avformat_open_input(&pFormatCtx,indexs,ifmt,&pOptions);

编译后错误提示*************
[avfoundation @ 0x7fe0a7038000] An error occurred: *** -[AVCaptureDevice_Tundra setActiveVideoMinFrameDuration:] Not supported - Supported ranges: (
"<AVFrameRateRange: 0x600000bc4020 1.00 - 1.00 (1000000 / 1000000 - 1000000 / 1000000)>"
), tried to set maxFrameRate to 30.000031 (1000000 / 30000030)>>>>>>>>>>>>>>avformat_open_input error


我把 av_dict_set(&pOptions,"framerate","30",0);改成 av_dict_set(&pOptions,"framerate","15",0);
编译后错误提示*************
[avfoundation @ 0x7f79fb013200] Selected framerate (15.000000) is not supported by the device
[avfoundation @ 0x7f79fb013200] Supported modes:
[avfoundation @ 0x7f79fb013200] 640x480@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 640x480@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 800x600@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 800x600@[2.500000 20.000000]fps
[avfoundation @ 0x7f79fb013200] 1024x768@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 1024x768@[15.000015 15.000015]fps
[avfoundation @ 0x7f79fb013200] 1280x720@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 1280x720@[10.000000 10.000000]fps
[avfoundation @ 0x7f79fb013200] 1280x960@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 1280x960@[5.000000 5.000000]fps
[avfoundation @ 0x7f79fb013200] 1600x1200@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 1600x1200@[5.000000 5.000000]fps
[avfoundation @ 0x7f79fb013200] 1920x1080@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 1920x1080@[5.000000 5.000000]fps
[avfoundation @ 0x7f79fb013200] 2048x1536@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 2048x1536@[3.750001 3.750001]fps
[avfoundation @ 0x7f79fb013200] 2592x1944@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 2592x1944@[2.500000 2.500000]fps
[avfoundation @ 0x7f79fb013200] 3264x2448@[2.500000 30.000030]fps
[avfoundation @ 0x7f79fb013200] 3264x2448@[1.000000 1.000000]fps
[avfoundation @ 0x7f79fb013200] 3840x2880@[2.500000 10.000000]fps
[avfoundation @ 0x7f79fb013200] 3840x2880@[1.000000 1.000000]fps
avformat_open_input error


我改成av_dict_set(&pOptions,"framerate","1",0);就能出图,但是帧率太低,好卡
编译后提示*************
[avfoundation @ 0x7fdb9105a800] Stream #0: not enough frames to estimate rate; consider increasing probesize

上面的代码要怎么改才能让帧率在15~30,可以avformat_open_input(); 返回值为0,请求解答,谢谢了

  • 写回答

14条回答 默认 最新

  • 尼尼帕 2023-09-21 13:53
    关注

    还有一点,我使用了两个摄像头做测试,一个带yuy2和mjpg格式的就有这问题,一个只有mjpg格式的就没这问题

    评论

报告相同问题?

问题事件

  • 系统已结题 9月29日
  • 修改了问题 9月21日
  • 创建了问题 9月21日

悬赏问题

  • ¥15 一道ban了很多东西的pyjail题
  • ¥15 关于#r语言#的问题:如何将生成的四幅图排在一起,且对变量的赋值进行更改,让组合的图漂亮、美观@(相关搜索:森林图)
  • ¥15 C++识别堆叠物体异常
  • ¥15 微软硬件驱动认证账号申请
  • ¥15 有人知道怎么在R语言里下载Git上的miceco这个包吗
  • ¥15 GPT写作提示指令词
  • ¥20 根据动态演化博弈支付矩阵完成复制动态方程求解和演化相图分析等
  • ¥20 关于DAC输出1.000V对分辨率和精度的要求
  • ¥15 华为超融合部署环境下RedHat虚拟机分区扩容问题
  • ¥15 哪位能做百度地图导航触点播报?