[Libav-user] Question about avdevice_list_devices() using.

Lukasz Marek lukasz.m.luki2 at gmail.com
Thu Jan 15 18:15:40 CET 2015


On 20 August 2014 at 16:16, Mike Charikov <ch_mike at mail.ru> wrote:

> Hi!
>
>
>
> I try to use avdevice_list_devices() for getting list of video devices,
> but don’t clearly understand, how to do that properly. How should I
> properly init AVFormatContext for calling avdevice_list_devices()?
>
>
>
> Tried something like that:
>
>
>
> int main() {
>
>
>
>                 avdevice_register_all();
>
>                 avcodec_register_all();
>
>
>
>                 AVFormatContext* format_context = avformat_alloc_context();
>
>                 AVInputFormat *fmt = av_find_input_format("dshow");
>
>                 AVDeviceInfoList *device_list=NULL;
>
>
>
>                 int err = avformat_open_input(&format_context, NULL, fmt,
> NULL);
>
>                 if (err != 0) {
>
>                                fprintf(stderr, "ffmpeg: Unable to open
> input: %d\n", err);
>
>                 }
>
>
>
>                 int i = avdevice_list_devices(format_context,
> &device_list);
>
>
>
>                 return 0;
>
> }
>
>
>
> But avformat_open_input() returns error (code -1414092869), and so does
> avdevice_list_devices() (code -40)
>
>
>
You better use one of the following that has been added previously:

int avdevice_list_input_sources(struct AVInputFormat *device, const char
*device_name,
                                AVDictionary *device_options,
AVDeviceInfoList **device_list);
int avdevice_list_output_sinks(struct AVOutputFormat *device, const char
*device_name,
                               AVDictionary *device_options,
AVDeviceInfoList **device_list);

alternatively you may want to check their implementation to answer your
question.

But, dshow doesn't implement this API yet, so you will get an error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150115/73b68326/attachment.html>


More information about the Libav-user mailing list