• 语音助手开发小记(2023.9.25)


    通道问题

           在使用函数swr_alloc_set_opts给SwrContext传递输入输出的音频参数时,需要设置通道,这里通道为2,但是通道布局不能传递2.比如AV_CH_LAYOUT_STEREO 实际值为3

    如果要计算通道布局的通道数使用函数av_get_channel_layout_nb_channels

    int src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
    1. swr_ctx = swr_alloc_set_opts(nullptr,
    2. dst_wave_fmt.ch_layout, //输出通道
    3. dst_wave_fmt.sample_fmt, //输出样本格式
    4. dst_wave_fmt.rate, //输出采样率
    5. AV_CH_LAYOUT_STEREO_DOWNMIX, //输入通道
    6. src_wave_fmt.sample_fmt, //输入样本格式
    7. src_wave_fmt.rate, //输入采样率
    8. 0, nullptr);

    声道map定义在 libavutil/channel_layout.c文件中

    1. static const struct {
    2. const char *name;
    3. int nb_channels;
    4. uint64_t layout;
    5. } channel_layout_map[] = {
    6. { "mono", 1, AV_CH_LAYOUT_MONO },
    7. { "stereo", 2, AV_CH_LAYOUT_STEREO },
    8. { "2.1", 3, AV_CH_LAYOUT_2POINT1 },
    9. { "3.0", 3, AV_CH_LAYOUT_SURROUND },
    10. { "3.0(back)", 3, AV_CH_LAYOUT_2_1 },
    11. { "4.0", 4, AV_CH_LAYOUT_4POINT0 },
    12. { "quad", 4, AV_CH_LAYOUT_QUAD },
    13. { "quad(side)", 4, AV_CH_LAYOUT_2_2 },
    14. { "3.1", 4, AV_CH_LAYOUT_3POINT1 },
    15. { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK },
    16. { "5.0(side)", 5, AV_CH_LAYOUT_5POINT0 },
    17. { "4.1", 5, AV_CH_LAYOUT_4POINT1 },
    18. { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK },
    19. { "5.1(side)", 6, AV_CH_LAYOUT_5POINT1 },
    20. { "6.0", 6, AV_CH_LAYOUT_6POINT0 },
    21. { "6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT },
    22. { "hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL },
    23. { "6.1", 7, AV_CH_LAYOUT_6POINT1 },
    24. { "6.1(back)", 7, AV_CH_LAYOUT_6POINT1_BACK },
    25. { "6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT },
    26. { "7.0", 7, AV_CH_LAYOUT_7POINT0 },
    27. { "7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT },
    28. { "7.1", 8, AV_CH_LAYOUT_7POINT1 },
    29. { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE_BACK },
    30. { "7.1(wide-side)", 8, AV_CH_LAYOUT_7POINT1_WIDE },
    31. { "octagonal", 8, AV_CH_LAYOUT_OCTAGONAL },
    32. { "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL },
    33. { "downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX, },
    34. { "22.2", 24, AV_CH_LAYOUT_22POINT2, },
    35. };

    PCMA播放问题

    播放PCMA

    ffplay -f s16le -ar 8000 -acodec pcm_alaw -ac 1 src.pcma

    播放PCMU

    ffplay -f s16le -ar 8000 -acodec pcm_mulaw -ac 1 src.pcmu

  • 相关阅读:
    如何测试 LoRaWAN 全球频段
    python flet 设置全局字体
    ssm+vue基于微信小程序的数学辅导教学学习系统#毕业设计
    21款奔驰GLS400升级电吸门 告别异响
    springboot大学生就业规划系统毕业设计-附源码191451
    人工智能在汽车业应用的五项挑战
    burp suite安装sqlmap插件
    原型链污染攻击
    spring boot + minio 8.5.4 遇到 okhttp3包冲突
    基于监督学习的多模态MRI脑肿瘤分割,使用来自超体素的纹理特征(Matlab代码实现)
  • 原文地址:https://blog.csdn.net/yunxiaobaobei/article/details/133279070