哪里可以获得libav *格式的完整列表?
答案 0 :(得分:14)
由于您要求使用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);
}
如果您还想查找特定格式的推荐编解码器,您可以迭代编解码器标签列表:
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);
}
答案 1 :(得分:2)
这取决于它的配置方式。构建libavformat时会显示一个列表。如果您已经构建了ffmpeg,也可以通过键入ffmpeg -formats
来查看列表。
还有一个列表适用于所有支持的格式here
答案 2 :(得分:0)
我不建议使用编解码器标签列表来找到适合容器的编解码器。接口(av_codec_get_id
,av_codec_get_tag2
)超出了我的理解范围,对我不起作用。更好地枚举并匹配所有编解码器和容器:
// enumerate all codecs and put into list
std::vector<AVCodec*> encoderList;
AVCodec * codec = nullptr;
while (codec = av_codec_next(codec))
{
// try to get an encoder from the system
auto encoder = avcodec_find_encoder(codec->id);
if (encoder)
{
encoderList.push_back(encoder);
}
}
// enumerate all containers
AVOutputFormat * outputFormat = nullptr;
while (outputFormat = av_oformat_next(outputFormat))
{
for (auto codec : encoderList)
{
// only add the codec if it can be used with this container
if (avformat_query_codec(outputFormat, codec->id, FF_COMPLIANCE_STRICT) == 1)
{
// add codec for container
}
}
}