mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
dshow: support choosing between devices with same name
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
68b531fe6a
commit
2f9b955918
@ -104,6 +104,14 @@ If set to @option{true}, print a list of devices and exit.
|
|||||||
If set to @option{true}, print a list of selected device's options
|
If set to @option{true}, print a list of selected device's options
|
||||||
and exit.
|
and exit.
|
||||||
|
|
||||||
|
@item video_device_number
|
||||||
|
Set video device number for devices with same name (starts at 0,
|
||||||
|
defaults to 0).
|
||||||
|
|
||||||
|
@item audio_device_number
|
||||||
|
Set audio device number for devices with same name (starts at 0,
|
||||||
|
defaults to 0).
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Examples
|
@subsection Examples
|
||||||
@ -122,6 +130,12 @@ Open video device @var{Camera}:
|
|||||||
$ ffmpeg -f dshow -i video="Camera"
|
$ ffmpeg -f dshow -i video="Camera"
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@item
|
||||||
|
Open second video device with name @var{Camera}:
|
||||||
|
@example
|
||||||
|
$ ffmpeg -f dshow -video_device_number 1 -i video="Camera"
|
||||||
|
@end example
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Open video device @var{Camera} and audio device @var{Microphone}:
|
Open video device @var{Camera} and audio device @var{Microphone}:
|
||||||
@example
|
@example
|
||||||
|
@ -31,6 +31,8 @@ struct dshow_ctx {
|
|||||||
IGraphBuilder *graph;
|
IGraphBuilder *graph;
|
||||||
|
|
||||||
char *device_name[2];
|
char *device_name[2];
|
||||||
|
int video_device_number;
|
||||||
|
int audio_device_number;
|
||||||
|
|
||||||
int list_options;
|
int list_options;
|
||||||
int list_devices;
|
int list_devices;
|
||||||
@ -249,6 +251,8 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
|
|||||||
IEnumMoniker *classenum = NULL;
|
IEnumMoniker *classenum = NULL;
|
||||||
IMoniker *m = NULL;
|
IMoniker *m = NULL;
|
||||||
const char *device_name = ctx->device_name[devtype];
|
const char *device_name = ctx->device_name[devtype];
|
||||||
|
int skip = (devtype == VideoDevice) ? ctx->video_device_number
|
||||||
|
: ctx->audio_device_number;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
|
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
|
||||||
@ -283,6 +287,7 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
|
|||||||
if (strcmp(device_name, buf))
|
if (strcmp(device_name, buf))
|
||||||
goto fail1;
|
goto fail1;
|
||||||
|
|
||||||
|
if (!skip--)
|
||||||
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
|
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf);
|
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf);
|
||||||
@ -938,6 +943,8 @@ static const AVOption options[] = {
|
|||||||
{ "list_options", "list available options for specified device", OFFSET(list_options), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_options" },
|
{ "list_options", "list available options for specified device", OFFSET(list_options), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_options" },
|
||||||
{ "true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_options" },
|
{ "true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_options" },
|
||||||
{ "false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_options" },
|
{ "false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_options" },
|
||||||
|
{ "video_device_number", "set video device number for devices with same name (starts at 0)", OFFSET(video_device_number), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC },
|
||||||
|
{ "audio_device_number", "set audio device number for devices with same name (starts at 0)", OFFSET(audio_device_number), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user