title: How do i get a list of all codecs available in ffmpeg?
body: <p>I have this code example I'm using in C:</p>
  <pre><code>//#define  UINT64_C  (uint64_t);
  
  #pragma comment(lib, &quot;Gdi32.lib&quot;)
  #pragma comment(lib, &quot;User32.lib&quot;)
  #pragma comment(lib, &quot;gdiplus.lib&quot;)
  
  #include &lt;windows.h&gt;
  #include &lt;gdiplus.h&gt;
  #include &lt;GdiPlusEnums.h&gt;
  
  using namespace Gdiplus;
  
  
  extern &quot;C&quot; {
  
  #include  &quot;libavcodec\avcodec.h&quot;
  #include &quot;libavutil\mathematics.h&quot;
  //#include &quot;libavcodec\avcodec.h&quot;
  
  WCHAR *fname;
  AVCodec *codec;
  AVCodecContext *c= NULL;
  int i, ret, x, y, got_output;
  int total_frame_counter;
  FILE *f;
  AVFrame *frame;
  AVPacket pkt;
  int codec_id;
  uint8_t endcode[] = { 0, 0, 1, 0xb7 };
  int errn;
  
  void Encoder_init()
  {
     avcodec_register_all();
      /* find the mpeg1 video encoder */
  
     codec_id = CODEC_ID_MPEG1VIDEO;
  
      codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
      if (!codec) {
          fprintf(stderr, &quot;Codec not found\n&quot;);
          exit(1);
      }
      c = avcodec_alloc_context3(codec);
      if (!c) {
          fprintf(stderr, &quot;Could not allocate video codec context\n&quot;);
          exit(1);
      }
      /* put sample parameters */
      c-&gt;bit_rate = 400000;
      /* resolution must be a multiple of two */
      c-&gt;width = 352;
      c-&gt;height = 288;
      /* frames per second */
      
     //c-&gt;time_base= (AVRational){1,25};
     c-&gt;time_base.num=1;c-&gt;time_base.den=25;
     
      c-&gt;gop_size = 10; /* emit one intra frame every ten frames */
      c-&gt;max_b_frames=1;
     c-&gt;pix_fmt = AV_PIX_FMT_YUV420P;
     /*
      if(codec_id == AV_CODEC_ID_H264)
          av_opt_set(c-&gt;priv_data, &quot;preset&quot;, &quot;slow&quot;, 0);
        */
  }
  
  const char *Encoder_GetCodecName( int id )
  {
     
     return avcodec_get_name( (AVCodecID)id );
  }
  </code></pre>
  <p>Then I have a header file in c++:</p>
  <pre><code>const char *Encoder_GetCodecName( int id );
  </code></pre>
  <p>Then I have another header file of the C++ where I'm using the <code>GetCodecName()</code> to get the List:</p>
  <pre><code>List&lt;String^&gt; ^GetCodecs()
     {
        List&lt;String^&gt; ^l = gcnew List&lt;String^&gt;;
  
        String ^s;
  
        for (int i=0;i&lt;3333;i++)
        {
        s = gcnew String(Encoder_GetCodecName( i ));
        l-&gt;Add(s);
        }
  
        return l;
     }
  </code></pre>
  <p>But I did now <code>i&lt;3333</code> so maybe one the of indexes are empty since there are less than 3333 codecs?</p>
  <p>So how can I get/calculate how many codecs there are in the ffmpeg library so I will do something like for example:</p>
  <pre><code>i &lt; codecs.Length
  </code></pre>
  <p>and not use <code>3333</code>?</p>