如何确定编解码器/容器组合是否与FFmpeg兼容? [英] How can I determine if a codec / container combination is compatible with FFmpeg?

查看:105
本文介绍了如何确定编解码器/容器组合是否与FFmpeg兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑重新混合一些容纳音频和视频的容器,以便提取最佳的第一个音频流,并将其存储在新的容器中,例如存在音频流.

I'm looking at re-muxing some containers holding audio and video such that I extract the best, first audio stream, and store it in a new container where e.g. only the audio stream is present.

创建FFmpeg的输出上下文如下:

The output context for FFmpeg is created like so:

AVFormatContext* output_context = NULL;
avformat_alloc_output_context2( &output_context, NULL, "mp4", NULL );

我有一个可接受的输出清单,例如MP4,M4A等…基本上是Apple的音频文件服务可以读取的那些文件:

I have a shortlist of acceptable outputs, e.g. MP4, M4A, etc … essentially those that are readable by Apple's Audio File Services:

kAudioFileAIFFType              = 'AIFF',
kAudioFileAIFCType              = 'AIFC',
kAudioFileWAVEType              = 'WAVE',
kAudioFileSoundDesigner2Type    = 'Sd2f',
kAudioFileNextType              = 'NeXT',
kAudioFileMP3Type               = 'MPG3',   // mpeg layer 3
kAudioFileMP2Type               = 'MPG2',   // mpeg layer 2
kAudioFileMP1Type               = 'MPG1',   // mpeg layer 1
kAudioFileAC3Type               = 'ac-3',
kAudioFileAAC_ADTSType          = 'adts',
kAudioFileMPEG4Type             = 'mp4f',
kAudioFileM4AType               = 'm4af',
kAudioFileM4BType               = 'm4bf',
kAudioFileCAFType               = 'caff',
kAudioFile3GPType               = '3gpp',
kAudioFile3GP2Type              = '3gp2',
kAudioFileAMRType               = 'amrf'

我的问题是这样:FFmpeg中是否有一个简单的API,可以在给定音频流的编解码器的情况下利用它来选择兼容的输出容器?

My question is this : is there an easy API in FFmpeg that can be leveraged to choose a compatible output container given the codec the audio stream is in?

推荐答案

对于每个单独的多路复用器,通常都有一个编解码器标记编写功能.该功能将检查另一个源文件中的列表或通过开关进行操作语句相同.没有中央花名册或容器匹配实用程序功能.最好的选择是在 libavcodec/allcodecs.c 中标识编解码器ID,然后在 libavformat/中标识该ID的grep,尤其是在带有enc后缀的文件中. matroskaenc.c .

For each individual muxer, there is usually a codec tag writing function.That function will check against a list in another source file or work through a switch statement in the same. There is no central roster or container-matching utility function. Your best bet is to identify the codec id in libavcodec/allcodecs.c and then grep in libavformat/ for that ID, particularly within files suffixed with enc e.g. matroskaenc.c.

这篇关于如何确定编解码器/容器组合是否与FFmpeg兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆