<div dir="ltr">Hi. I wrote the code for getting a list of input devices:<div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>avdevice_register_all();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">AVFormatContext</span><span style="color:rgb(192,192,192)"> </span>*formatContext<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>avformat_alloc_context();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">AVInputFormat</span><span style="color:rgb(192,192,192)"> </span>*inputFormat<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">NULL</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">while</span>((inputFormat<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>av_input_video_device_next(inputFormat)))</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>formatContext-><span style="color:rgb(128,0,0)">iformat</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>inputFormat;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,128)">AVDeviceInfoList</span><span style="color:rgb(192,192,192)"> </span>*deviceList<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">NULL</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>avdevice_list_devices(formatContext,<span style="color:rgb(192,192,192)"> </span>&deviceList);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">if</span>(deviceList)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(128,128,0)">for</span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>i<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span>i<span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span>deviceList-><span style="color:rgb(128,0,0)">nb_devices</span>;<span style="color:rgb(192,192,192)"> </span>++i)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span><span style="color:rgb(128,0,128)">AVDeviceInfo</span><span style="color:rgb(192,192,192)"> </span>*device<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>deviceList-><span style="color:rgb(128,0,0)">devices</span>[i];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span><font color="#000080">..........</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">       </span>avdevice_free_list_devices(&deviceList);</pre><pre style="margin-top:0px;margin-bottom:0px">     }</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">It fails with SIGSEGV on avdevice_list_devices when it comes to v4l2 input format.</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Why does it fail?</pre><pre style="margin-top:0px;margin-bottom:0px">How can I get list of video devices?</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Btw I'm using Ubuntu 16.04</pre></div></div>