Ffmpeg Output Stream Mapping with -Filter_Complex Channelsplit

Ffmpeg Output Stream Mapping with -Filter_Complex Channelsplit

The goal is to generate mono audio tracks with codec s16_le in the output file, independently of the audio track/channel layout of the input file. All that without dynamically creating the ffmpeg commandline. That is why i am trying to get this work without explicitly accessing input audio channels.

In my head, this should work:

ffmpeg -i F:\test.3gp  -filter_complex "[0:v]copy[vid];[0:a]channelsplit[aud]" -map [vid] -map [aud] -c:a pcm_s16le f:\splitted.mxf

But it brings up this error when used together with .mxf muxer:

ffmpeg version N-94423-ga0c1970781 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190716
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 32.100 / 56. 32.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\test.3gp':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:02.88, start: 0.000000, bitrate: 20219 kb/s
    Stream #0:0(und): Video: vp9 (Profile 0) (vp09 / 0x39307076), yuv420p(tv), 1080x1920, 25011 kb/s, SAR 64:27 DAR 4:3, 27.16 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
File 'f:\splitted.mxf' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 (vp9) -> copy
  Stream #0:1 (mp3float) -> channelsplit
  channelsplit:FR -> Stream #0:0 (pcm_s16le)
  copy -> Stream #0:1 (mpeg2video)
  channelsplit:FL -> Stream #0:2 (pcm_s16le)
Press [q] to stop, [?] for help
[mxf @ 000001d0f51a8800] there must be exactly one video stream and it must be the first one
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Error initializing output stream 0:2 --
Conversion failed!

As we see in the Stream mapping: section, the video stream is mapped to output track 0:1 while i was under the impression that as i provided -map options it should be remapped to 0:0.

Any clue is welcome!

2
Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.