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

查看:23
本文介绍了如何确定编解码器/容器组合是否与 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?

推荐答案

对于每个单独的 muxer,通常都有一个编解码器标记写入函数.该函数将检查另一个源文件中的列表或通过 开关工作 语句相同.没有中央花名册或容器匹配实用程序功能.最好的办法是在 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天全站免登陆