FFMPEG学习----遍历所支持的解码器

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 10:01   11   0
下面简单介绍一下遍历ffmpeg中的解码器信息的方法(这些解码器以一个链表的形式存储):

1.注册所有编解码器:av_register_all();

2.声明一个AVCodec类型的指针,比如说AVCodec* p;

3.调用av_codec_next()函数,即可获得指向链表下一个解码器的指针,循环往复可以获得所有解码器的信息。注意,如果想要获得指向第一个解码器的指针,则需要将该函数的参数设置为NULL。

/**
* If c is NULL, returns the first registered codec,
* if c is non-NULL, returns the next registered codec after c,
* or NULL if c is the last one.
*/

int main(void)
{
 char *info = (char *)malloc(40000);
 memset(info, 0, 40000);

 av_register_all();

 AVCodec *c_temp = av_codec_next(NULL);

 while (c_temp != NULL)
 {
  if (c_temp->decode != NULL)
  {
   strcat(info, "[Decode]");
  }
  else
  {
   strcat(info, "[Encode]");
  }
  switch (c_temp->type)
  {
  case AVMEDIA_TYPE_VIDEO:
   strcat(info, "[Video]");
   break;
  case AVMEDIA_TYPE_AUDIO:
   strcat(info, "[Audeo]");
   break;
  default:
   strcat(info, "[Other]");
   break;
  }
  sprintf(info, "%s %10s\n", info, c_temp->name);
  c_temp = c_temp->next;
 }
 puts(info);
 free(info);
 return 0;
}


.....

[Decode][Video] libvpx
[Encode][Video] libvpx-vp9
[Decode][Video] libvpx-vp9
[Encode][Audeo] libwavpack
[Encode][Video] libwebp
[Encode][Video] libx264
[Encode][Video] libx264rgb
[Encode][Video] libx265
[Encode][Video] libxavs
[Encode][Video] libxvid
[Decode][Video] bintext
[Decode][Video] xbin
[Decode][Video] idf
[Encode][Video] h264_qsv
[Encode][Video] hevc_qsv
[Encode][Video] mpeg2_qsv

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP