<div dir="ltr"><div style="font-size:12.8px">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 (I have uploaded a part of the Hex Version of the FLV file Link : <a href="https://drive.google.com/file/d/0B3tyQGRngqX-Zy02OVVnU1NuNUk/view?usp=sharing">https://drive.google.com/file/d/0B3tyQGRngqX-Zy02OVVnU1NuNUk/view?usp=sharing</a>). 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(I have uploaded the entire AVPacket data obtained and the outputs obtained from the two functions Link: <a href="https://drive.google.com/file/d/0B3tyQGRngqX-STF6TkhWN3JyM0k/view?usp=sharing">https://drive.google.com/file/d/0B3tyQGRngqX-STF6TkhWN3JyM0k/view?usp=sharing</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 query the decoder below. Any suggestions will be helpful.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks in Advance</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">[Code]</div><div style="font-size:12.8px">AVFormatContext *pFormatCtx;</div><div style="font-size:12.8px">AVCodecContext  *pCodecCtx;</div><div style="font-size:12.8px">AVCodec         *pCodec;</div><div style="font-size:12.8px">AVFrame<span style="white-space:pre-wrap">                      </span>*pFrameRGB;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">   </span></div><div style="font-size:12.8px">#if FFMPEG_2_8</div><div style="font-size:12.8px">avformat_open_input(&pFormatCtx, strFileName, NULL, NULL) ;</div><div style="font-size:12.8px">#else</div><div style="font-size:12.8px">av_open_input_file(&pFormatCtx, strFileName, NULL, 0, NULL) ;</div><div style="font-size:12.8px">#endif //FFMPEG_2_8<br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">size_t videoStream=pFormatCtx->nb_streams;</div><div style="font-size:12.8px">bool streamFound = false ;</div><div style="font-size:12.8px">for(size_t i=0; i<pFormatCtx->nb_streams; i++)</div><div style="font-size:12.8px">{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">    </span>#if FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">        </span>if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">    </span>#else</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>#endif //FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">   </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span>videoStream = i;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>streamFound = true ; </div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                </span>break;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">        </span>}</div><div style="font-size:12.8px">}</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">if(streamFound)</div><div style="font-size:12.8px">{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">  </span>pCodecCtx=pFormatCtx->streams[videoStream]->codec;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">  </span>// Find the decoder for the video stream</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>pCodec=avcodec_find_decoder(pCodecCtx->codec_id);</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">  </span>if(pCodec==NULL)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>return false; // Codec not found</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">  </span>// Open codec</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>#if FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">        </span>if(avcodec_open2(pCodecCtx, pCodec,NULL)<0)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">        </span>#else</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>if(avcodec_open(pCodecCtx, pCodec)<0)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>#endif //FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">   </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span>return false; // Could not open codec</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>}</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">     </span></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>#if FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">        </span>pFrameRGB=av_frame_alloc() ;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">  </span>#else</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>pFrameRGB=avcodec_alloc_frame();</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>#endif //FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">   </span>if(pFrameRGB==NULL)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                   </span>return false; //No Memory</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">     </span></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">      </span>while(true)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">   </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span>AVPacket packet ;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>if (av_read_frame(pFormatCtx, &packet) < 0)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">            </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                     </span>break ;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">               </span>}</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                     </span></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">          </span>int frameFinished;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">            </span>if (packet.stream_index == videoStream)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">               </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                     </span>#if FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                        </span>avcodec_decode_video2(pCodecCtx, pFrameRGB, &frameFinished, &packet);</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                 </span>#else</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                 </span>avcodec_decode_video(pCodecCtx, pFrameRGB, &frameFinished, packet.data, packet.size);</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                     </span>#endif //FFMPEG_2_8</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">           </span>}</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>if(frameFinished !=0)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">         </span>{</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                     </span>break ;</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">               </span>}</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">     </span>}</div><div style="font-size:12.8px">}</div><div style="font-size:12.8px">[/Code]</div></div>