c++ - 如何在 C++ 中使用 ffmpeg 获取 DirectShow 设备列表?

标签 c++ windows ffmpeg directshow

我正在尝试使用 ffmpeg 获取 dshow 设备列表。我无法得到它,但 ffmpeg 自己得到它。这是代码。它为 avdevice_list_input_sources 返回 AVERROR(ENOSYS)。但是 avformat_open_input 打印所有设备。如何在 C++ 代码中获取 dshow 设备和选项。

    avdevice_register_all();
    AVInputFormat *iformat = av_find_input_format("dshow");
    printf("========Device Info=============\n");
    AVDeviceInfoList *device_list = NULL;
    AVDictionary* options = NULL;
    //av_dict_set(&options, "list_devices", "true", 0);
    int result = avdevice_list_input_sources(iformat, NULL, options, &device_list);

    if (result < 0)
        printf("Error Code:%s\n", av_err2str(result));//Returns -40 AVERROR(ENOSYS)
    else printf("Devices count:%d\n", result);

    AVFormatContext *pFormatCtx = avformat_alloc_context();
    AVDictionary* options2 = NULL;
    av_dict_set(&options2, "list_devices", "true", 0);
    avformat_open_input(&pFormatCtx, NULL, iformat, &options2);
    printf("================================\n");

最佳答案

“我们”还没有探测 libav 以返回设备列表。所以它要么解析 ffmpeg.exe -f dshow -list_devices true -i dummy 的输出,要么自己使用 dshow api 枚举它们:

https://trac.ffmpeg.org/wiki/DirectShow#Howtoprogrammaticallyenumeratedevices

关于c++ - 如何在 C++ 中使用 ffmpeg 获取 DirectShow 设备列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51991436/

相关文章:

c++ - GDB 的奇怪行为

c++ - 调整窗口大小会导致右边框附近出现污迹

c++ - 为什么随机数和MSYS2都一样?

ffmpeg - 使用 Arc 和 FFmpeg 在 Elixir 中创建上传视频的背景版本

c++ - 使用 ffmpeg 从网络摄像头捕获帧和从 micro 捕获音频并保存到文件

c++ - Arduino 子串不起作用

c++ - Eclipse CDT C++ 错误

c++ - 重复 ffmpeg 流(libavcodec/libavformat)

c++ - 比较同一类的 2 个对象(覆盖 == 运算符)c++

windows - 用于查找状态为 "not responding"的应用程序的脚本,在 Windows XP 中终止并重新启动该应用程序