如何在 C++ 中使用 ffmpeg 获取 DirectShow 设备列表?
How to get DirectShow device list with ffmpeg in c++?
我正在尝试使用 ffmpeg 获取 dshow 设备列表。我无法得到它,但 ffmpeg 自己得到它。这是代码。它 returns AVERROR(ENOSYS) avdevice_list_input_sources。但是 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");
"We" 尚未将 libav 检测到 return 设备列表。所以它要么解析 ffmpeg.exe -f dshow -list_devices true -i dummy
的输出,要么自己使用 dshow api's:
枚举它们
https://trac.ffmpeg.org/wiki/DirectShow#Howtoprogrammaticallyenumeratedevices
我正在尝试使用 ffmpeg 获取 dshow 设备列表。我无法得到它,但 ffmpeg 自己得到它。这是代码。它 returns AVERROR(ENOSYS) avdevice_list_input_sources。但是 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");
"We" 尚未将 libav 检测到 return 设备列表。所以它要么解析 ffmpeg.exe -f dshow -list_devices true -i dummy
的输出,要么自己使用 dshow api's:
https://trac.ffmpeg.org/wiki/DirectShow#Howtoprogrammaticallyenumeratedevices