search
LoginSignup
1
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

FFmpegで5.1ch音声をモノラル音声6つに切り出す(Channel Layoutのメモ)

経緯

Unityで360°動画を再生したい!
音声も3Dにしたい!
AudioSourceを周囲に配置しなきゃ!
音声をchannel毎に切り出さなきゃ…?

前提

ffmpeg version 3.2.2

やり方

ffmpeg -i in.mov -filter_complex 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]' -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]' front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]' side_right.wav

filter_complexオプションのchannelsplitでチャンネルの切り分け方を指定する。

5.1ch以外のパターン

まずAudioの形式を調べる

$ ffmpeg -i in.mov
(省略)
    Stream #0:0(eng): Audio: pcm_s24be (lpcm / 0x6D63706C), 48000 Hz, 4.0, s32 (24 bit), 4608 kb/s (default)
(省略)

48000 Hzの後の4.0で4.0chとわかる
4.0chのChannel LayoutはFL+FR+FC+BCなので、

ffmpeg -i in.mov -filter_complex 'channelsplit=channel_layout=4.0[FL][FR][FC][BC]' -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]' front_center.wav -map '[BC]' bc.wav

で切り出せる。
めでたしめでたし。

Channel-Layout

channel layoutいろいろあるのでまとめ
https://www.ffmpeg.org/ffmpeg-utils.html#Channel-Layout

channelのリスト

id channel
FL front left
FR front right
FC front center
LFE low frequency
BL back left
BR back right
FLC front left-of-center
FRC front right-of-center
BC back center
SL side left
SR side right
TC top center
TFL top front left
TFC top front center
TFR top front right
TBL top back left
TBC top back center
TBR top back right
DL downmix left
DR downmix right
WL wide left
WR wide right
SDL surround direct left
SDR surround direct right
LFE2 low frequency 2

channel layout のリスト

id channel layout
mono FC
stereo FL+FR
2.1 FL+FR+LFE
3.0 FL+FR+FC
3.0(back) FL+FR+BC
4.0 FL+FR+FC+BC
quad FL+FR+BL+BR
quad(side) FL+FR+SL+SR
3.1 FL+FR+FC+LFE
5.0 FL+FR+FC+BL+BR
5.0(side) FL+FR+FC+SL+SR
4.1 FL+FR+FC+LFE+BC
5.1 FL+FR+FC+LFE+BL+BR
5.1(side) FL+FR+FC+LFE+SL+SR
6.0 FL+FR+FC+BC+SL+SR
6.0(front) FL+FR+FLC+FRC+SL+SR
hexagonal FL+FR+FC+BL+BR+BC
6.1 FL+FR+FC+LFE+BC+SL+SR
6.1 FL+FR+FC+LFE+BL+BR+BC
6.1(front) FL+FR+LFE+FLC+FRC+SL+SR
7.0 FL+FR+FC+BL+BR+SL+SR
7.0(front) FL+FR+FC+FLC+FRC+SL+SR
7.1 FL+FR+FC+LFE+BL+BR+SL+SR
7.1(wide) FL+FR+FC+LFE+BL+BR+FLC+FRC
7.1(wide-side) FL+FR+FC+LFE+FLC+FRC+SL+SR
octagonal FL+FR+FC+BL+BR+BC+SL+SR
downmix DL+DR

まとめ

FFmpegは奥が深いなぁ…

参考

channelsplit
https://ffmpeg.org/ffmpeg-filters.html#channelsplit
Channel Layout
https://ffmpeg.org/ffmpeg-utils.html#Channel-Layout

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
1
Help us understand the problem. What are the problem?