跳至主要内容

FFmpeg:調整音高和速度

調整音高(Pitch Shifting)

ffmpeg -i input.wav -af "rubberband=pitch=1.0595" output.wav

pitch 的值是頻率倍數,不是半音數。

計算公式為:pitch = 2^(半音數 / 12)

移調計算倍數
升 1 個半音2^(1/12)≈ 1.0595
升 2 個半音2^(2/12)≈ 1.1225
升 3 個半音2^(3/12)≈ 1.1892
降 1 個半音2^(-1/12)≈ 0.9439
降 2 個半音2^(-2/12)≈ 0.8909
降 3 個半音2^(-3/12)≈ 0.8409
高八度2^(12/12)= 2.0000
低八度2^(-12/12)= 0.5000

調整速度(Time Stretching)

ffmpeg -i input.wav -af "rubberband=tempo=1.25" output.wav

tempo 的值是倍數

  • > 1.0 → 加速(1.25 = 快 25%)
  • < 1.0 → 減速(0.8 = 慢 20%)

調速度時音高不會改變,這就是 rubberband 的重點。

同時調整速度和音調

兩個參數可以一起用:

ffmpeg -i input.wav -af "rubberband=tempo=1.25:pitch=1.0595" output.wav

這樣就是「加速 25% 且升一個半音」,音高和速度完全獨立控制,互不干擾。