【问题标题】:Concatenate wav files ignore if # channels is 2如果 #channels 为 2,则连接 wav 文件将忽略
【发布时间】:2017-11-23 21:06:30
【问题描述】:

我需要连接文件夹中的所有 wav 文件。

我尝试使用命令

sox folder_name/*.wav folder_name.wav

但是出错了

sox FAIL sox: Input files must have the same # channels

原来该文件夹中的 2864 个 wav 文件中只有 21 个有 2 个通道而不是 1 个。

我怎样才能忽略具有 2 个通道的 21 个文件并将所有 2843 个 wav 与 1 个通道连接起来?

【问题讨论】:

    标签: bash macos audio terminal sox


    【解决方案1】:

    使用soxi获取所有一个通道文件,将它们放入一个数组中,然后调用sox

    for file in folder_name/*.wav; do
      if soxi "$file" | grep -q 'Channel.*1'; then
        files+=("$file")
      fi
    done
    
    sox "${files[@]}" folder_name.wav
    

    【讨论】:

    • 这样做是错误的,我希望合并所有 1 通道文件。我只能选择那些,但我不能吗?
    • 你能用soxi-c选项吗?
    • 是的,我不知道它存在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2018-12-23
    相关资源
    最近更新 更多