Где взять полный список форматов libav *? - PullRequest
3 голосов
/ 31 мая 2010

Где взять полный список форматов libav *?

Ответы [ 3 ]

14 голосов
/ 12 июня 2012

Поскольку вы запросили форматы libav *, я предполагаю, что вы ищете пример кода.

Чтобы получить список всех кодеков, используйте API av_codec_next для просмотра списка доступных кодеков.

/* 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);
}
2 голосов
/ 31 мая 2010

Это зависит от того, как оно настроено. Список отображается при сборке libavformat. Вы также можете увидеть список, набрав ffmpeg -formats, если у вас есть встроенный ffmpeg. Здесь также есть список всех поддерживаемых форматов здесь

0 голосов
/ 14 февраля 2019

Я бы не рекомендовал использовать список тегов кодеков, чтобы найти подходящие кодеки для контейнера. Интерфейс (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
        }
    }
}
...