title: ignore "channel_layout" when working with multichannel audio in ffmpeg
body: <p>I'm working with multichannel audio files (higher-order ambisonics), that typically have at <em>least</em> 16 channels.</p>
  <p>Sometimes I'm only interested in a subset of the audiochannels (e.g. the first 25 channels of a file that contains even more channels).</p>
  <p>For this I have a script like the following, that takes a multichannel input file, an output file and the number of channels I want to extract:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/sh
  infile=$1
  outfile=$2
  channels=$3
  
  channelmap=$(seq -s&quot;|&quot; 0 $((channels-1)))
  
  ffmpeg -y -hide_banner \
    -i &quot;${infile}&quot; \
    -filter_complex &quot;[0:a]channelmap=${channelmap}&quot; \
    -c:a  libopus -mapping_family 255 -b:a 160k -sample_fmt s16 -vn -f webm -dash 1 \
    &quot;${outfile}&quot;
  </code></pre>
  <p>The actual channel extraction is done via the <a href="http://ffmpeg.org/ffmpeg-filters.html#channelmap" rel="nofollow noreferrer"><em>channelmap</em> filter</a>, that is invoked with something like <code>-filter:complex &quot;[0:a]channelmap=0|1|2|3&quot;</code></p>
  <p>This works great with 1,2,4 or 16 channels.</p>
  <p>However, it fails with 9 channels, and 25 and 17 (and generally anything with &gt;&gt;16 channels).</p>
  <p>The error I get is:</p>
  <pre class="lang-sh prettyprint-override"><code>$ ffmpeg -y -hide_banner -i input.wav  -filter_complex &quot;[0:a]channelmap=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16&quot; -c:a libopus -mapping_family 255 -b:a 160k  -sample_fmt s16 -vn -f webm -dash 1 output.webm
  Input #0, wav, from 'input.wav':
    Duration: 00:00:09.99, bitrate: 17649 kb/s
      Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 25 channels, s16, 17640 kb/s
  [Parsed_channelmap_0 @ 0x5568874ffbc0] Output channel layout is not set and cannot be guessed from the maps.
  [AVFilterGraph @ 0x5568874fff40] Error initializing filter 'channelmap' with args '0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16'
  Error initializing complex filters.
  Invalid argument
  </code></pre>
  <p>So ffmpeg cannot guess the channel layout for a 17 channel file.
  <code>ffmpeg -layouts</code> only lists channel layouts with 1,2,3,4,5,6,7,8 &amp; 16.</p>
  <p>However, I really don't care about the channel layout. The entire concept of &quot;channel layout&quot; is centered around the idea, that each audio channel should go to a different speaker.
  But my audio channels are not speaker feeds at all.</p>
  <p>So I tried providing explicit channel layouts, with something like <code>-filter_complex &quot;[0:a]channelmap=map=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16:channel_layout=unknown&quot;</code>, but this results in an error when parsing the channel layout:</p>
  <pre class="lang-sh prettyprint-override"><code>$ ffmpeg -y -hide_banner -i input.wav  -filter_complex &quot;[0:a]channelmap=map=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16:channel_layout=unknown&quot; -c:a  libopus -mapping_family 255 -b:a 160k  -sample_fmt s16 -vn -f webm -dash 1 output.webm
  Input #0, wav, from 'input.wav':
    Duration: 00:00:09.99, bitrate: 17649 kb/s
      Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 25 channels, s16, 17640 kb/s
  [Parsed_channelmap_0 @ 0x55b60492bf80] Error parsing channel layout: 'unknown'.
  [AVFilterGraph @ 0x55b604916d00] Error initializing filter 'channelmap' with args 'map=0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16:channel_layout=unknown'
  Error initializing complex filters.
  Invalid argument
  </code></pre>
  <p>I also tried values like <code>any</code>, <code>all</code>, <code>none</code>, <code>0x0</code> and <code>0xFF</code> with the same result.
  I tried using <code>mono</code> (as the channels are kind-of independent), but <code>ffmpeg</code> is trying to be clever and tells me that a <em>mono</em> layout must not have 17 channels.</p>
  <p>I know that <code>ffmpeg</code> can handle multi-channel files without a layout.
  E.g. converting a 25-channel file without the <code>-filter_complex &quot;...&quot;</code> works without problems, and <code>ffprobe</code> gives me an <code>unknown</code> channel layout.</p>
  <p>So: how do I tell <code>ffmpeg</code> to just not care about the channel_layout when creating an output file that only contains a subset of the input channels?</p>