2010-05-30 61 views

回答

2

这取决于它是如何配置的。当您构建libavformat时会显示一个列表。如果您已经构建了ffmpeg,则还可以通过输入ffmpeg -formats来查看列表。 还有一个所有支持的格式的列表here

12

既然你问libav *格式,我猜你是在一个代码示例之后。

要获取所有编解码器的列表,请使用av_codec_next api遍历可用编解码器的列表。

/* initialize libavcodec, and register all codecs and formats */ 
av_register_all(); 

/* Enumerate the codecs*/ 
AVCodec * codec = av_codec_next(NULL); 
while(codec != NULL) 
{ 
    fprintf(stderr, "%s\n", codec->long_name); 
    codec = av_codec_next(codec); 
} 

要获得的格式列表,以同样的方式使用av_format_next:

AVOutputFormat * oformat = av_oformat_next(NULL); 
while(oformat != NULL) 
{ 
    fprintf(stderr, "%s\n", oformat->long_name); 
    oformat = av_oformat_next(oformat); 
} 

如果你也想找出推荐编解码器特定的格式,你可以迭代codec tags list:

AVOutputFormat * oformat = av_oformat_next(NULL); 
while(oformat != NULL) 
{ 
    fprintf(stderr, "%s\n", oformat->long_name); 
    if (oformat->codec_tag != NULL) 
    { 
     int i = 0; 

     CodecID cid = CODEC_ID_MPEG1VIDEO; 
     while (cid != CODEC_ID_NONE) 
     { 
      cid = av_codec_get_id(oformat->codec_tag, i++); 
      fprintf(stderr, " %d\n", cid); 
     } 
    } 
    oformat = av_oformat_next(oformat); 
} 
相关问题