google/ExoPlayer · error · UnsupportedOperationException

Default channel mixing coefficients for {inputChannelCount}-

Error message

Default channel mixing coefficients for {inputChannelCount}->{outputChannelCount} are not yet implemented.

What it means

ChannelMixingMatrix.create(inputChannelCount, outputChannelCount) only has built-in coefficients for three cases: same count (identity), 1->2 (mono to stereo, both gains 1f) and 2->1 (stereo to mono, both gains 0.5f). Any other count combination throws UnsupportedOperationException stating the defaults are 'not yet implemented'. This is an API limitation, not a runtime media error.

Source

Thrown at library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingMatrix.java:173

    for (int i = 0; i < coefficients.length; i++) {
      scaledCoefficients[i] = scale * coefficients[i];
    }
    return new ChannelMixingMatrix(inputChannelCount, outputChannelCount, scaledCoefficients);
  }

  private static float[] createMixingCoefficients(int inputChannelCount, int outputChannelCount) {
    if (inputChannelCount == outputChannelCount) {
      return initializeIdentityMatrix(outputChannelCount);
    }
    if (inputChannelCount == 1 && outputChannelCount == 2) {
      // Mono -> stereo.
      return new float[] {1f, 1f};
    }
    if (inputChannelCount == 2 && outputChannelCount == 1) {
      // Stereo -> mono.
      return new float[] {0.5f, 0.5f};
    }
    throw new UnsupportedOperationException(
        "Default channel mixing coefficients for "
            + inputChannelCount
            + "->"
            + outputChannelCount
            + " are not yet implemented.");
  }

  private static float[] initializeIdentityMatrix(int channelCount) {
    float[] coefficients = new float[channelCount * channelCount];
    for (int c = 0; c < channelCount; c++) {
      coefficients[channelCount * c + c] = 1f;
    }
    return coefficients;
  }

  private static float[] checkCoefficientsValid(float[] coefficients) {
    for (int i = 0; i < coefficients.length; i++) {
      if (coefficients[i] < 0f) {

View on GitHub (pinned to dd430f7053)

Solutions

  1. Supply explicit coefficients instead of defaults: build the matrix via the constructor ChannelMixingMatrix.create(inputCount, outputCount, float[] coefficients) with your own downmix gains (e.g. ITU-R BS.775 5.1-to-stereo coefficients).
  2. For surround-to-stereo, route the extra surround channels with -0.707/0.707 style gains and LFE at 0 in a custom coefficient array.
  3. Or chain two supported conversions where possible (e.g. 6->2 is not chainable, but 1->anything can go 1->2 then 2->N if you write N coefficients anyway — usually the custom array is the right answer).

Example fix

// before
ChannelMixingMatrix.create(6, 2); // throws UnsupportedOperationException

// after
// 5.1 -> stereo downmix (L R C LFE Ls Rs -> L R), ITU-R BS.775-ish
float[] coeffs = {
    1f, 0f,        // L -> L,R
    0f, 1f,        // R
    0.707f, 0.707f, // C
    0f, 0f,        // LFE
    0.707f, 0f,    // Ls (note: sign convention per spec)
    0f, 0.707f     // Rs
};
ChannelMixingMatrix.create(6, 2, coeffs);
Defensive patterns

Strategy: validation

Validate before calling

public static boolean hasDefaultMixing(int in, int out) {
  return in == out || (in == 1 && out == 2) || (in == 2 && out == 1);
}
// Use before calling ChannelMixingMatrix.create(in, out)
if (!hasDefaultMixing(in, out)) {
  coefficients = computeCustomCoefficients(in, out); // must be non-negative
  matrix = ChannelMixingMatrix.create(in, out, coefficients);
} else {
  matrix = ChannelMixingMatrix.create(in, out);
}

Prevention

When it happens

Trigger: Calling ChannelMixingMatrix.create(6, 2), create(1, 6), create(8, 2) or any pair other than (n,n), (1,2), (2,1).

Common situations: Downmixing 5.1/7.1 surround to stereo for Bluetooth or TV speakers; upmixing mono to more than 2 channels for multichannel DSP pipelines.

Related errors


AI-assisted analysis of google/ExoPlayer@dd430f7053 (2026-08-14). Data as JSON: /api/errors/533654d75af9f180. Report an issue: GitHub.