title: avformat_find_stream_info not filling out the nb_streams and streams
body: <p>Hi this is the first time I haven't been able to find my question already answered so this is the first time I post something here.</p>
  
  <p>I have this codesniplet that is my attempt to follow the few tutorials I have found on getting some basic libav functionality (working my way to extracting video frames).</p>
  
  <pre><code>      1 #ifndef INT64_C
        2 #define INT64_C(c) (c ## LL)
        3 #define UINT64_C(c) (c ## ULL)
        4 #endif
        5 
        6 extern "C" {
        7 #include &lt;libavformat/avformat.h&gt;
        8 #include &lt;libavcodec/avcodec.h&gt;
        9 #include &lt;libavutil/avutil.h&gt;
        10 }
        11 #include &lt;iostream&gt;
        12 using namespace std;
        13 #define FILENAME "/home/jon/Videos/testvideo.avi"
        14 
        15 
        16 int main(int argc, char** argv)
        17 {
        18     av_register_all();
        19     AVFormatContext * avFormatPtr = avformat_alloc_context();
        20     if (avformat_open_input(&amp;avFormatPtr, FILENAME, NULL, NULL) != 0)
        21         cout&lt;&lt;"Error while calling avformat_open_input (probably invalid file  format)"&lt;&lt;endl;
        22     if (avformat_find_stream_info(avFormatPtr, NULL) &lt; 0)
        23         cout&lt;&lt;"Error while calling avformat_find_stream_info"&lt;&lt;endl;
        24     av_dump_format(avFormatPtr,0,FILENAME,false);
        25 
        26     cout&lt;&lt;"There are "&lt;&lt;avFormatPtr-&gt;nb_streams&lt;&lt;" streams"&lt;&lt;endl;
        27     unsigned int video_codec_id = -1;
        28     for (unsigned int i = 0; i &lt; avFormatPtr-&gt;nb_streams; ++i) {
        29         cout&lt;&lt;"loop iteration "&lt;&lt;i&lt;&lt;endl;
        30         if(avFormatPtr-&gt;streams[i]-&gt;codec-&gt;codec_type==AVMEDIA_TYPE_VIDEO)
        31         {
        32             cout&lt;&lt;"Found video "&lt;&lt;i&lt;&lt;endl;
        33             video_codec_id = i;
        34         }
        35         cout&lt;&lt;"debug point";
        36     }
        37 
        38     cout&lt;&lt;"fin"&lt;&lt;endl;
        39}           
  </code></pre>
  
  <p>Now the problem is that this always segfaults, here is the output</p>
  
  <pre><code>    Input #0, avi, from '/home/jon/Videos/testvideo.avi':
        Metadata:
          encoder         : Lavf53.21.0
        Duration: 00:01:51.08, start: 0.000000, bitrate: 17129 kb/s
          Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 1920x1088 [PAR 1:1 DAR 30:17], 25 tbr, 25 tbn, 25 tbc
      There are 157328928 streams
      loop iteration 0
      Segmentation fault (core dumped)
  </code></pre>
  
  <p>The number of streams part changes every time leading my to think that it is just pointing to a random place in the memory so I guess I must be misunderstanding something about </p>
  
  <pre><code>    avformat_find_stream_info
  </code></pre>
  
  <p>Now this also always segfaults in the first loop iteration so I guess streams hasn't been initialized either. 
  Thanks in advance for any help. </p>