Trim 使用 SoX / FFmpeg 等从音频文件中关闭 N 个样本

Trim off N samples from audio file using SoX / FFmpeg etc

有没有办法 trim 使用 SoX / FFmpeg 或类似工具从音频文件中删除 N 个样本?

使用atrim filter:

ffmpeg -i input -af atrim=start_sample=65614:end_sample=102400 output
  • start_sample - 应输出的第一个样本的编号。

  • end_sample - 应该丢弃的第一个样本的数量。

使用 SoX trim :

sox in.wav out.wav trim 0s 1000s

修剪前 1000 个样本,偏移量为 0。

's' here means 'sample', not 'second'. To trim by 'seconds' you should remove 's'


至trim 指定样本范围:

sox in.wav out.wav trim 5000s 100s

修剪 100 个样本,从 5000 到 5100 (5000 秒 - 样本偏移量,100 秒 - 偏移后 trim 的样本数)

sox in.wav out.wav trim 123456788s 1s

修剪第 123456789 个样本 (123456788s - 样本偏移量,1s - 偏移后到 trim 的样本数)