Rob*_*Rob 15
既然你要求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);
}
Run Code Online (Sandbox Code Playgroud)
要获取格式列表,请以相同的方式使用av_format_next:
AVOutputFormat * oformat = av_oformat_next(NULL);
while(oformat != NULL)
{
fprintf(stderr, "%s\n", oformat->long_name);
oformat = av_oformat_next(oformat);
}
Run Code Online (Sandbox Code Playgroud)
如果您还想查找特定格式的推荐编解码器,可以迭代编解码器标签列表:
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);
}
Run Code Online (Sandbox Code Playgroud)