首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >这是libavformat的avformat_open_input()的第二个参数问题

这是libavformat的avformat_open_input()的第二个参数问题
EN

Stack Overflow用户
提问于 2022-03-12 06:45:38
回答 1查看 68关注 0票数 0

我计划从Windows上的两个摄像头中导入实时的视频/音频图像,然后使用FFMPEG的av_image_fill_arrays()函数将这两个图像合并成一个Rect进行流传输。

如下图所示,我们也在考虑同步这两个摄像机。

在这里输入图像描述1:https://i.stack.imgur.com/AqEGm.png

但是在此之前,avformat_open_input()我不知道如何使用这个函数。

代码语言:javascript
运行
复制
AVFormatContext     *inputContext = nullptr;
AVInputFormat       *inputFormat = av_find_input_format("dshow"); // linux -> v412
AVDictionary        *options = nullptr;

char temp[128] = {0x00,};
snprintf(temp, 127, "video_size=1920x1080;pixel_format=yuyv422;framerate=30;");
av_dict_parse_string(&options, str_tmp, "=", ";", 0);

if (ret = avformat_open_input(&m_InputContext, "video=@device_pnp_\\\\?\\usb#vid_1bcf&pid_2c99&mi_00#8&3ea22a0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global", inputFormat, &options) != 0)
{
    // exception
    av_dict_free(&options);
    std::cerr << "avformat_open_input() error: " << str_tmp << std::endl;
    return -1;
}

在第二个参数中输入的值是在cmd中输入以下命令时可以获得的另一个名称。(添加转义字符)

代码语言:javascript
运行
复制
ffmpeg -list_devices true -f dshow -i dummy

我应该用什么方法来获得相机的控制?

EN

Stack Overflow用户

发布于 2022-03-12 22:21:54

看来你得给avdevice_register_all()打电话了。

在我的机器中,以下代码工作(具有不同的设备名称):

代码语言:javascript
运行
复制
avdevice_register_all();

AVFormatContext     *inputContext = avformat_alloc_context();
AVInputFormat       *inputFormat = av_find_input_format("dshow");
AVDictionary        *options = nullptr;

int ret;

if (ret = avformat_open_input(&inputContext, "video=@device_pnp_\\\\?\\usb#vid_1bcf&pid_2c99&mi_00#8&3ea22a0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global", inputFormat, &options) != 0)
{
    // exception
    av_dict_free(&options);
    std::cerr << "avformat_open_input() error: " << std::endl;
    return -1;
}

如果它不起作用,尝试使用FFplay (命令行工具)来测试它:

代码语言:javascript
运行
复制
ffplay -f dshow -i "video=@device_pnp_\\?\usb#vid_1bcf&pid_2c99&mi_00#8&3ea22a0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71447538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档