[FFmpeg-user] decoding video frames

Bob Self bobslf at gmail.com
Mon Dec 19 14:37:02 CET 2011


If I open a mpeg4 file that is almost 2 hours long and read the frames with
this function, I only get 2247 frames returned before this function returns
false. Is this the correct way to get frames? Why do I only get 2247 frames?


bool get_next_frame(void)  {
   int   got_picture;
   AVPacket packet;

   while (av_read_frame(m_pFormatCtx, &packet) >= 0)  {
      if (packet.stream_index == m_videoStream) {
         avcodec_decode_video2(m_pCodecCtx, m_pFrame, &got_picture, &packet);
   if (got_picture)  {
            av_free_packet(&packet);
            return true;
         }
      }
      av_free_packet(&packet);
   }
   return false;
}


More information about the ffmpeg-user mailing list