title: How to split 5.1 audio into discrete AAC streams in FFmpeg 4.0
body: <p>Up until FFmpeg v4.0 I have been able to run the following command on an input video file that contains an H.264 video track and either AC3 or DTS audio stream and produce an MP4 that has 6 streams of audio. Each stream corresponds to a channel of the 5.1 audio.</p>
  <pre><code>ffmpeg -i INPUT.MKV -vcodec copy -filter_complex channelsplit=channel_layout=5.1 -acodec aac -movflags faststart OUTPUT.MP4
  </code></pre>
  <p>It even worked on Stereo tracks and put the L and R channels into the proper places and produced some extraneous silent tracks for the other 4 channels.</p>
  <p>But now in v4.0.1 I get the following error:</p>
  <blockquote>
  <p>[aac @ 0x7f7f65001e00] Unsupported channel layout</p>
  <p>Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height</p>
  <p>Conversion failed!</p>
  </blockquote>
  <p>Changing the command to be the following does not improve things:</p>
  <pre><code>ffmpeg -i INPUT.MKV -vcodec copy -filter_complex &quot;channelsplit=channel_layout=5.1[FL][FR][FC][LFE][BL][BR]&quot; -acodec aac -movflags faststart OUTPUT.MP4
  </code></pre>
  <p>It gives the following error:</p>
  <blockquote>
  <p>Filter channelsplit:BR has an unconnected output</p>
  </blockquote>
  <p>(Note that BL/BR and SL/SR both produce the same error about BR)</p>
  <p>This MP4 file structure is useful for playing back inside of Unity with virtual speakers placed in the environment.</p>
  <p>My end goal:</p>
  <pre><code>- MP4 (MOOV Atom at the Front)
      -H.264 Video Stream
      -AAC Audio Stream - FL
      -AAC Audio Stream - FR
      -AAC Audio Stream - FC
      -AAC Audio Stream - LFE
      -AAC Audio Stream - SL
      -AAC Audio Stream - SR
  </code></pre>