How to properly query all video devices in system using libavdevice?
opening input with int err = avformat_open_input(&context, NULL, fmt, NULL);
fails because device name is not provided (second parameter is device name, if one provides "/dev/video0"
for example it finds that device only):
avcodec_register_all();
avdevice_register_all();
AVFormatContext* context = avformat_alloc_context();
AVInputFormat *fmt = av_find_input_format("video4linux");
printf("trying to open input");
int err = avformat_open_input(&context, "/dev/video0", fmt, NULL);
if(err != 0){
fprintf(stderr, "ffmpeg failed to open input");
}
static struct AVDeviceInfoList* devices_list;
avdevice_list_devices(context, &devices_list);
int devices_count = devices_list->nb_devices;
for(int i = 0; i < devices_count; i++){
printf("Checking device nr. %d \n", i);
AVDeviceInfo* current_device_info = devices_list->devices[i];
printf("Find Device: %s", current_device_info->device_description);
}
avformat_free_context(context);
How Can AVFormatContext can be initialized to find all v4l2 devices? I imagine that if context partially initialized (let's say takes all v4l2devices) it should query everything properly. When context run with avformat_open_input
one must provide exact device name beforehand.