title: FFmpeg av_read_frame returns packets from audio stream
body: <p>I am currently trying to learn the <em>FFmpeg API</em>, following <a href="http://dranger.com/ffmpeg/tutorial01.html" rel="nofollow noreferrer">this tutorial</a>. However, I already have issues with the first lesson on video decoding. My code is basically the same as the one from the tutorial except I am using C++. My issue is that the video stream does not match the one from the packet returned by <code>av_read_frame</code>.</p>
  
  <p>The video stream is obtained looping on the available streams until the video stream is found.</p>
  
  <pre><code>for(int i = 0; i &lt; pFormatCtx-&gt;nb_streams; i++) { // nb_streams == 2
  
      if(pFormatCtx-&gt;streams[i]-&gt;codec-&gt;codec_type==AVMEDIA_TYPE_VIDEO) {
          videoStream = i; 
          break; // videoStream == 0
      }
  }
  </code></pre>
  
  <p>Then when retrieving the frame data, it seams grabbing the audio channel. </p>
  
  <pre><code>while(av_read_frame(pFormatCtx, &amp;packet) &gt;= 0) { // read returns 0
  
      // Is this a packet from the video stream?
      if(packet.stream_index == videoStream) { 
          //packet.stream_index == 1, which correspond to the audio stream
      } 
  }
  </code></pre>
  
  <p>I have not found examples online where this test is actually failing. Have I miss some way to specify the <code>stream_index</code> that is not in the tutorial? Maybe the tutorial is not up to date and is doing something wrong? If so, what is the correct way to extract the frame data? In case that matters, I am using the latest <em>FFmpeg 4.0.2</em> build, on <em>Windows 64-bits</em>, compiling with <em>Visual Studio 2017</em>. </p>
  
  <p>On videos with no sound, the two streams match and I am able to decode and display the frames correctly.</p>