Reputation: 77
I'm trying to get dshow device list with ffmpeg. I cannot get it but ffmpeg gets it by its own. Here is the code. It returns AVERROR(ENOSYS) for avdevice_list_input_sources. But avformat_open_input prints all devices. How can I get dshow devices and options in c++ code.
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");
Upvotes: 1
Views: 4634
Reputation: 66741
"We" haven't plumbed libav to return the device list yet. So it's either parse the output of ffmpeg.exe -f dshow -list_devices true -i dummy
or enumerate them yourself using dshow api's:
https://trac.ffmpeg.org/wiki/DirectShow#Howtoprogrammaticallyenumeratedevices
Upvotes: 2