NDI: Support more than 8 channels of raw audio
It seems that ndisrc
uses the fallback channel-mask from gst_audio_channel_get_fallback_mask
to configure the audio channel positions (see https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/blob/main/net/ndi/src/ndisrc/receiver.rs, inside create_audio_info
). This fallback only supports up to 8 audio channels. When there are more than 8 audio channels, gst_audio_channel_get_fallback_mask
returns a channel-mask of 0. This will crash Gstreamer when gst_audio_channel_positions_from_mask
is called later on.
When ingesting an NDI stream containing more (in my case, up to 16) raw audio channels, Gstreamer needs to be able to select channels or apply a custom channel-mask, since audio encoders such as fdkaacenc
may only support up to 8 audio channels.
$ gst-launch-1.0 ndisrc ndi-name="GC-DEV2 (OBS)" ! ndisrcdemux name=demux demux.audio ! queue ! audioconvert ! audio/x-raw,channels=2 ! fdkaacenc ! fakesink
I've included a small patch that sets the positions of the first 8 audio channels to match the fallback channel-mask, and uses the 13th and higher channel-mask bits to map any remaining channels (so theoretically, this supports up to 52 channels). This way, the first 8 audio channels will always be positioned as valid 8.1 audio and the remaining channels will not be assigned an interfering position.
I realize that this might not be an ideal solution. Gstreamer itself seems to assign up to 28 valid audio channel positions using its default_channel_order
. Alternatively, you could require ndisrc
to be configured with a channel-mask property when you want to ingest an NDI stream with more than 8 raw audio channels.