Opened 3 months ago
#11163 new enhancement
avdevice_list_input_sources for dshow fails on machines with no video capture devices.
Reported by: | Rishi | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avdevice |
Version: | 6.1.1 | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug: avdevice_list_input_sources fails on machines with no video capture devices. While this sounds like by design, there are some machines with audio only capture devices, which an api user can then filter through.
How to reproduce:
It requires a Windows machine with no video capture devices.
const AVInputFormat* inputFormat = av_find_input_format("dshow");
AVDeviceInfoList* p;
FFmpegReturnFalseIfFail(avdevice_list_input_sources(inputFormat, nullptr, nullptr, &p));
This stems from here libavdevice/dshow.c
ret = dshow_cycle_devices(avctx, devenum, VideoDevice, VideoSourceDevice, NULL, NULL, &device_list);
if (ret < S_OK)
goto error;
ret = dshow_cycle_devices(avctx, devenum, AudioDevice, AudioSourceDevice, NULL, NULL, &device_list);
From https://learn.microsoft.com/en-us/previous-versions/ms784969(v=vs.85)
ICreateDevEnum::CreateClassEnumerator returns S_FALSE if the category does not exist ...
So why not cycle the audio devices if the video category does not exist, ie if specifically S_FALSE is returned. Happy to put in a patch, but does this sound like a right ask?
My main scenario is to capture Stereo Mix Audio or any other recording devices.
I am using this in my binary linked against FFmpeg 6_1 that I build on my own.
$ git log -1
commit 36126e4c142e43cc703f4b8c535d388ac5e403a4 (HEAD -> master)
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri May 3 23:25:10 2024 +0200
avcodec/exr: Fix preview overflow
Fixes: CID1515456 Unintentional integer overflow
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
rishi@DESKTOP-0NQHKQI MINGW64 ~/localgitrepos/ffmpeg (master)
$ git branch -vv
- master 36126e4c14 [origin/master: behind 1596] avcodec/exr: Fix preview overflow