ffmpeg---输入命令分组

ffmpeg命令通常较长,通过分组便于解析和管理。主要分为全局、输入源和输出源三组,涉及libavcodec和libavformat的options_table.h。split_commandline函数负责分组,find_option查找匹配命令,add_opt根据参数属性分类,存入OptionGroup结构体。-i标志指示输入源分组,后续为输出源分组。
摘要由CSDN通过智能技术生成

使用ffmpeg都是使用命令的。实际使用中,命令都会很长,为了解析这些命令,一般都会通过将命令分组。将命令分组,一来方便解析,二来方便管理。
那么,内部机制中是如何对命令进行分组的?下面简单分析ffmpeg的命令分组机制。
ffmpeg一般情况下,将命令分成三组(如果细分的话,还有一个分类AVDictionary ):
1.全局 —–如:-filter_complex -loglevel
2.输入源相关的设置
3.输出源相关的设置

static const OptionGroupDef global_group = { "global" };
static const OptionGroupDef groups[] = {
    [GROUP_OUTFILE] = { "output file",  NULL, OPT_OUTPUT },
    [GROUP_INFILE]  = { "input file",   "i",  OPT_INPUT },
};  
    AVDictionary *codec_opts;
    AVDictionary *format_opts;
    AVDictionary *resample_opts;
    AVDictionary *sws_dict;
    AVDictionary *swr_opts;

这个分类涉及到目录libavcodec和libavformat下的文件options_table.h以及其它参数
libavcodec/options_table.h—->static const AVOption avcodec_options[]
libavformat/options_table.h—->static const AVOption static const AVOption avformat_options[]
这个两个数组保存着与编解码和封装相关的参数设置

下面简单分析split_commandline是如何给命令进行分组的:

int split_commandline(OptionParseContext *octx, int argc, char *argv[],
                      const OptionDef *options,
                      const OptionGroupDef *groups, int nb_groups)     //nb_groups = 2
{
    int optindex = 1;
    int dashdash = -2;

    /* perform system-dependent conversions for arguments list */
    prepare_app_arguments(&argc, &argv);

    /*基本的内存分配
    *OptionGroupDef 与OptionParseContext建立联系
    */
    init_parse_context(octx, groups, nb_groups);
    av_log(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值