title: avcodec_encode_video2 return -542398533 Generic error in an external library only with h264 encoder
body: <pre><code>pAvframe = GetVideoFrame();
  
  av_init_packet(&amp;pkt);
  /* encode the image */
  ret = avcodec_encode_video2(pAvCodecCtx, &amp;pkt, pAvframe, &amp;got_packet); //return Generic error in external library
  if (ret &lt; 0) 
  {
      char errbuf[128];
      const char *errbuf_ptr = errbuf;
  
      if (av_strerror(ret, errbuf, sizeof(errbuf)) &lt; 0)
          errbuf_ptr = strerror(AVUNERROR(ret));
      av_log(NULL, AV_LOG_ERROR, "%s\n", errbuf_ptr);
  
      _stprintf_s(szErr,MAX_PATH, _T("Error encoding video frame:: "));
      LOG_ENTRY_ERROR(E_FAIL,szErr);
  }
  
  
  
  if(ret &gt;= 0)
  {
      ret = WriteFrameToFile(&amp;pAvCodecCtx-&gt;time_base, m_stVideoStream.pAVStream, &amp;pkt);
      if(ret &lt; 0)
      {
          av_packet_unref(&amp;pkt);
  
      }
  }
  </code></pre>
  
  <p>It always return - -542398533 "Generic error in an external library" only with h.264 encoder please provide solution if gop is zero it work some time.</p>