今まではテンポ(再生速度)を変えるにはatempoフィルタを、ピッチ(高低)を変えるにはasetrateフィルタを使っていたが、rubberbandフィルタはasetrateフィルタで変わる周波数を変えずにピッチとテンポを変えることができ、atempoフィルタよりも品質がよい場合がある。
rubberbandフィルタは別途ライブラリをインストールしないと使えないのと、現在は 64bit に未対応である。
標準フィルタを使う場合。
映像と音声の pts を扱う setpts, asetpts
ピッチを任意の周波数に変更するasetrate
基本コマンド
2倍速再生にする(映像は2倍速にはならない)。
ffplay input -af rubberband=tempo=2
映像も2倍速再生にする。
ffplay input -vf setpts=1/2*PTS -af rubberband=tempo=2
ffplay input -vf setpts=1/2*PTS -af atempo=2
公式ドキュメント:FFmpeg Filters Documentation : rubberband
インストールする
$ git clone https://github.com/mia-0/rubberband rubberband $ cd rubberband $ make && make install
これでインストールできるが、Makefile の冒頭に PREFIX でインストール場所を指定できる。XhmikosR’s Buildsを使っている場合は cc がなくエラーが出るので MSYS/mingw/bin/gcc.exe を MSYS/mingw/bin/cc.exe にコピー&リネームする。
2020年12月にXhmikosR’s Buildsの配布は終了した。
ffmpeg の configure オプションには、
--enable-gpl --enable-librubberband --pkg-config-flags="--static"をつける。
インストールしたライブラリを適宜移動して rubberband.pc の上部を適宜以下のように書き換える。
prefix=/mingw/i686-w64-mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
オプション
詳細にオプションが指定できるが説明は省略。
- tempo[double]
 テンポ(音声再生速度)指定
 既定値:1
 範囲:0.01 から 100 まで
- pitch[double]
 ピッチ(音の高さ)指定
 既定値:1
 範囲:0.01 から 100 まで
- transients[int]
- 0, crisp:既定値
- 256, mixed
- 512, smooth
 
- detector[int]
- 0, compound:既定値
- 1024, percussive
- 2048, soft
 
- phase[int]
- 0, laminar:既定値
- 8192, independent
 
- window[int]
- 0, standard:既定値
- 1048576, short
- 2097152, long
 
- smoothing[int]
- 0, off:既定値
- 8388608, on
 
- formant[int]
- 0, shifted:既定値
- 16777216, preserved
 
- pitchq[int]
- 0, quality:既定値
- 33554432, speed
- 67108864, consistency
 
- channels[int]
- 0, apart:既定値
- 268435456, together