title: FFMPEG avcodec_decode_video2 got_picture_ptr Differing Behaviour
body: <p>Am Currently updating our FFMPEG library usage from a pretty old version(0.5) to 2.8. As part of the change, had replaced avcodec_decode_video to avcodec_decode_video2. However, am noticing quite a difference in the way avcodec_decode_video2 functions compared to the old avcodec_decode_video. For the same packet (same data), 'avcodec_decode_video2' gives got_picture_ptr as zeo whereas the old 'avcodec_decode_video' was giving a non-zero value. In the example that am describing here, am decoding an FLV file with VideoCodec:H264-MPEG-4 AVC (part 10) and AudioCodec:MPEG AAC Audio (Am attaching a part of the Hex Version of the FLV file in FLV_Sample.Hex <a href="https://drive.google.com/file/d/0B3tyQGRngqX-Zy02OVVnU1NuNUk/view?usp=sharing" rel="nofollow">FLV_Sample_Hex</a>). The original flv file is too large). For the first AVPacket (obtained from av_read_frame), got_picture_ptr from 'avcodec_decode_video2' is zero but old 'avcodec_decode_video' gives 296(Am attaching the entire AVPacket data obtained and the outputs obtained from the two functions in the file FFMPEG_Decoding_Packet_Info.txt <a href="https://drive.google.com/file/d/0B3tyQGRngqX-STF6TkhWN3JyM0k/view?usp=sharing" rel="nofollow">FFMPEG_Decoding_Packet_Info</a>). Continuing on, the new 'avcodec_decode_video2' keeps giving 'Zero' till the 23rd Packet where it gives 1. So its not like avcodec_decode_video2 keeps giving zero. My main dilemma is that am not sure if this difference in behaviour is due to the changes in 'avcodec_decode_video2' or any errors that I have made in using the Decoder. I have put a snippet of the code that am using to use the decoder below. Any suggestions will be helpful.</p>
  
  <pre><code>AVFormatContext *pFormatCtx;
  AVCodecContext  *pCodecCtx;
  AVCodec         *pCodec;
  AVFrame         *pFrameRGB;
  
  #if FFMPEG_2_8
  avformat_open_input(&amp;pFormatCtx, strFileName, NULL, NULL) ;
  #else
  av_open_input_file(&amp;pFormatCtx, strFileName, NULL, 0, NULL) ;
  #endif //FFMPEG_2_8
  
  size_t videoStream=pFormatCtx-&gt;nb_streams;
  bool streamFound = false ;
  for(size_t i=0; i&lt;pFormatCtx-&gt;nb_streams; i++)
  {
      #if FFMPEG_2_8
      if(pFormatCtx-&gt;streams[i]-&gt;codec-&gt;codec_type==AVMEDIA_TYPE_VIDEO)
      #else
      if(pFormatCtx-&gt;streams[i]-&gt;codec-&gt;codec_type==CODEC_TYPE_VIDEO)
      #endif //FFMPEG_2_8
      {
          videoStream = i;
          streamFound = true ; 
          break;
      }
  }
  
  if(streamFound)
  {
      pCodecCtx=pFormatCtx-&gt;streams[videoStream]-&gt;codec;
  
      // Find the decoder for the video stream
      pCodec=avcodec_find_decoder(pCodecCtx-&gt;codec_id);
      if(pCodec==NULL)
          return false; // Codec not found
  
      // Open codec
      #if FFMPEG_2_8
      if(avcodec_open2(pCodecCtx, pCodec,NULL)&lt;0)
      #else
      if(avcodec_open(pCodecCtx, pCodec)&lt;0)
      #endif //FFMPEG_2_8
      {
          return false; // Could not open codec
      }
  
      #if FFMPEG_2_8
      pFrameRGB=av_frame_alloc() ;
      #else
      pFrameRGB=avcodec_alloc_frame();
      #endif //FFMPEG_2_8
      if(pFrameRGB==NULL)
              return false; //No Memory
  
      while(true)
      {
          AVPacket packet ;
  
          if (av_read_frame(pFormatCtx, &amp;packet) &lt; 0)
          {
              break ;
          }
  
  
          int frameFinished;
          if (packet.stream_index == videoStream)
          {
              #if FFMPEG_2_8
              avcodec_decode_video2(pCodecCtx, pFrameRGB, &amp;frameFinished, &amp;packet);
              #else
              avcodec_decode_video(pCodecCtx, pFrameRGB, &amp;frameFinished, packet.data, packet.size);
              #endif //FFMPEG_2_8
          }
  
          if(frameFinished !=0)
          {
              break ;
          }
      }
  }
  </code></pre>