如何在ffmpeg 6.1中设置“ch_layout”?

问题描述 投票:0回答:1

在 6.1 Ffmpeg 中,使用“ch_layout”代替“channel_layout”和“number”。 “ch_layout”是“AVChannelLayout *”类型。该类型在channel_layout.h中定义,该文件中也定义了某种“ch_layout”。 如果我想使用“av_dict_set_int()”将“ch_layout”设置为“AV_CHANNEL_LAYOUT_STEREO”,我应该在“value”中填写什么?

/**
 * Macro to define native channel layouts
 *
 * @note This doesn't use designated initializers for compatibility with C++ 17 and older.
 */
#define AV_CHANNEL_LAYOUT_MASK(nb, m) \
    { /* .order */ AV_CHANNEL_ORDER_NATIVE, \
      /* .nb_channels */  (nb), \
      /* .u.mask */ { m }, \
      /* .opaque */ NULL }

/**
 * @name Common pre-defined channel layouts
 * @{
 */
#define AV_CHANNEL_LAYOUT_MONO              AV_CHANNEL_LAYOUT_MASK(1,  AV_CH_LAYOUT_MONO)
#define AV_CHANNEL_LAYOUT_STEREO            AV_CHANNEL_LAYOUT_MASK(2,  AV_CH_LAYOUT_STEREO)
#define AV_CHANNEL_LAYOUT_2POINT1           AV_CHANNEL_LAYOUT_MASK(3,  AV_CH_LAYOUT_2POINT1)
#define AV_CHANNEL_LAYOUT_2_1               AV_CHANNEL_LAYOUT_MASK(3,  AV_CH_LAYOUT_2_1)
/**
 * Convenience wrapper for av_dict_set() that converts the value to a string
 * and stores it.
 *
 * Note: If ::AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
 */
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);
c ffmpeg
1个回答
0
投票

TLDR 它接受与之前相同的值,这里是直接来自 ffmpeg 源的示例

AVChannelLayout layout = (s->output_channels == 1) ? (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO :
                                             (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
av_opt_set_chlayout(s->swr, "out_chlayout",  &layout,            0);
av_opt_set_chlayout(s->swr, "in_chlayout",   &layout,            0);

https://github.com/FFmpeg/FFmpeg/blob/2f8bf90054a5f7455f35b8705163f81c4413d779/libavcodec/opusdec.c#L726-L731

© www.soinside.com 2019 - 2024. All rights reserved.