google/ExoPlayer · error · UnhandledAudioFormatException

Unhandled input format: {audioFormat}

Error message

Unhandled input format: {audioFormat}

What it means

ChannelMixingAudioProcessor.onConfigure throws AudioProcessor.UnhandledAudioFormatException when the incoming encoding is anything other than C.ENCODING_PCM_16BIT. The processor performs matrix mixing on 16-bit PCM only, so any other encoding (8-bit, 24-bit, 32-bit integer, float, or encodings like AC3 passthrough) is rejected at configure time before any audio is queued.

Source

Thrown at library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingAudioProcessor.java:60

  public ChannelMixingAudioProcessor() {
    matrixByInputChannelCount = new SparseArray<>();
  }

  /**
   * Stores a channel mixing matrix for processing audio with a given {@link
   * ChannelMixingMatrix#getInputChannelCount() channel count}. Overwrites any previously stored
   * matrix for the same input channel count.
   */
  public void putChannelMixingMatrix(ChannelMixingMatrix matrix) {
    int inputChannelCount = matrix.getInputChannelCount();
    matrixByInputChannelCount.put(inputChannelCount, matrix);
  }

  @Override
  protected AudioFormat onConfigure(AudioFormat inputAudioFormat)
      throws UnhandledAudioFormatException {
    if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {
      throw new UnhandledAudioFormatException(inputAudioFormat);
    }
    @Nullable
    ChannelMixingMatrix channelMixingMatrix =
        matrixByInputChannelCount.get(inputAudioFormat.channelCount);
    if (channelMixingMatrix == null) {
      throw new UnhandledAudioFormatException(
          "No mixing matrix for input channel count", inputAudioFormat);
    }
    if (channelMixingMatrix.isIdentity()) {
      return AudioFormat.NOT_SET;
    }
    return new AudioFormat(
        inputAudioFormat.sampleRate,
        channelMixingMatrix.getOutputChannelCount(),
        C.ENCODING_PCM_16BIT);
  }

  @Override

View on GitHub (pinned to dd430f7053)

Solutions

  1. Place ToInt16PcmAudioProcessor (or set the sink's float/pcm output to 16-bit) before the ChannelMixingAudioProcessor so it receives ENCODING_PCM_16BIT.
  2. Configure the decoder (e.g. DefaultRenderersFactory setEnableDecoderFloatOutput(false)) so PCM output is 16-bit.
  3. Catch UnhandledAudioFormatException and fall back to a chain without channel mixing for unsupported encodings.

Example fix

// before
ChannelMixingAudioProcessor mixer = new ChannelMixingAudioProcessor();
mixer.configure(new AudioFormat(48000, 2, C.ENCODING_PCM_FLOAT)); // throws

// after
ToInt16PcmAudioProcessor to16 = new ToInt16PcmAudioProcessor();
AudioFormat pcm16 = to16.configure(floatFormat);
mixer.configure(pcm16);
Defensive patterns

Strategy: validation

Validate before calling

if (inputFormat.encoding != C.ENCODING_PCM_16BIT) {
  inputFormat = toInt16Processor.configure(inputFormat); // convert first
}
AudioFormat out = channelMixingProcessor.configure(inputFormat);

Try / catch

try {
  mixer.configure(inputFormat);
} catch (AudioProcessor.UnhandledAudioFormatException e) {
  // Passthrough without mixing
  mixerDisabled = true;
}

Prevention

When it happens

Trigger: Calling channelMixingAudioProcessor.configure(format) (directly or via an AudioProcessingPipeline) with encoding != C.ENCODING_PCM_16BIT — e.g. ENCODING_PCM_FLOAT from an Ogg/Opus decoder or ENCODING_PCM_24BIT from high-resolution FLAC.

Common situations: Building a custom DefaultAudioSink processor chain that includes channel mixing while the source outputs float or 24-bit PCM; enabling an equalizer/mixing DSP for lossless content; device default audio format changes after Bluetooth route switching.

Related errors


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