[FFmpeg-user] Creating surround sound from mono wav files

CherylJosie exwyeorzee at yahoo.com
Sun Dec 23 22:38:03 EET 2018


Hi all,
I am trying to merge a surround sound file from discrete mono files with ffmpeg.
The -map_channel function does not accept multiple audio input streams, and so far I have only managed to create stereo with -filter_complex amerge.
amerge seems to ignore additional channels beyond stereo at the output, even though it parses them as inputs.

Apologies for my lack of expertise. I've only used ffmpeg and Linux for simple things (scripted IC design workflows mainly), and despite my engineering background I'm not a recording engineer.
I'm running
$ ffmpeg -i Front\ Left.wav -i Front\ Right.wav -i Front\ Center.wav -i Rear\ Left.wav -i Rear\ Right.wav -i Surround\ Left.wav -i Surround\ Right.wav -filter_complex amerge out.wavffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, wav, from 'Front Left.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #1.0 : mono
Input #1, wav, from 'Front Right.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #2.0 : mono
Input #2, wav, from 'Front Center.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #3.0 : mono
Input #3, wav, from 'Rear Left.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #3:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #4.0 : mono
Input #4, wav, from 'Rear Right.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #4:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #5.0 : mono
Input #5, wav, from 'Surround Left.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #5:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
Guessed Channel Layout for  Input Stream #6.0 : mono
Input #6, wav, from 'Surround Right.wav':
  Duration: 03:40:20.06, bitrate: 768 kb/s
    Stream #6:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 1 channels, s16, 768 kb/s
[Parsed_amerge_0 @ 0x23ba960] No channel layout for input 1
[Parsed_amerge_0 @ 0x23ba960] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, wav, to 'out.wav':
  Metadata:
    ISFT            : Lavf56.40.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      encoder         : Lavc56.60.100 pcm_s16le
Stream mapping:
  Stream #0:0 (pcm_s16le) -> amerge:in0
  Stream #1:0 (pcm_s16le) -> amerge:in1
  amerge -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
size= 2478762kB time=03:40:20.06 bitrate=1536.0kbits/s    
video:0kB audio:2478762kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000003%

and the resulting file is
$ mediainfo out.wavGeneral
Complete name                            : out.wav
Format                                   : Wave
File size                                : 2.36 GiB
Duration                                 : 3h 40mn
Overall bit rate mode                    : Constant
Overall bit rate                         : 1 536 Kbps
Writing application                      : Lavf56.40.101

Audio
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 1
Duration                                 : 3h 40mn
Bit rate mode                            : Constant
Bit rate                                 : 1 536 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Stream size                              : 2.36 GiB (100%)
on
$ uname -a
Linux media1-AX370-Gaming-5 4.4.0-139-generic #165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

The output is stereo of the first two channels only regardless of how many additional channels are given as inputs. I tried both 7 and 8 inputs and the resulting file was stereo.

This project is on a shoestring budget. I'm attempting to do it all with open-source software because it's all I have access to.

Thanks.Cheryl


More information about the ffmpeg-user mailing list