On 16.09.2016 23:39, Timur Guseynov wrote:
Hi. I wrote the code for getting a list of input devices:
avdevice_register_all();
AVFormatContext*formatContext=avformat_alloc_context();
AVInputFormat*inputFormat=NULL;
while((inputFormat=av_input_video_device_next(inputFormat)))
{
formatContext->iformat=inputFormat;
AVDeviceInfoList*deviceList=NULL;
avdevice_list_devices(formatContext,&deviceList);
if(deviceList)
{
for(inti=0;i<deviceList->nb_devices;++i)
{
AVDeviceInfo*device=deviceList->devices[i];
..........
}
}
avdevice_free_list_devices(&deviceList);
}
It fails with SIGSEGV on avdevice_list_devices when it comes to v4l2 input
format.
Why does it fail?
How can I get list of video devices?
Btw I'm using Ubuntu 16.04
I guess input device private data is not initialized, try to add this
code right after formatContext->iformat=inputFormat, just replace s with
formatContext
if (s->iformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->iformat->priv_data_size);
if (s->iformat->priv_class) {
*(const AVClass**)s->priv_data= s->iformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
} else
s->priv_data = NULL;
Maybe ff_alloc_input_device_context function should be moved to
libavdevice's public API
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user