google/ExoPlayer · error · UnhandledAudioFormatException
Unhandled input format:
Error message
Unhandled input format:
What it means
ChannelMappingAudioProcessor implements per-channel output mapping (setOutputChannels, e.g. stereo-to-mono downmix order control) and only supports 16-bit PCM input. During sink configuration (onConfigure), if channel mapping is active and the incoming audio is not ENCODING_PCM_16BIT, it throws UnhandledAudioFormatException so the sink/configuration layer knows this processor cannot be inserted into the chain.
Source
Thrown at library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java:63
*
* @param outputChannels The mapping from input to output channel indices, or {@code null} to
* leave the input unchanged.
*/
public void setChannelMap(@Nullable int[] outputChannels) {
pendingOutputChannels = outputChannels;
}
@Override
@CanIgnoreReturnValue
public AudioFormat onConfigure(AudioFormat inputAudioFormat)
throws UnhandledAudioFormatException {
@Nullable int[] outputChannels = pendingOutputChannels;
if (outputChannels == null) {
return AudioFormat.NOT_SET;
}
if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) {
throw new UnhandledAudioFormatException(inputAudioFormat);
}
boolean active = inputAudioFormat.channelCount != outputChannels.length;
for (int i = 0; i < outputChannels.length; i++) {
int channelIndex = outputChannels[i];
if (channelIndex >= inputAudioFormat.channelCount) {
throw new UnhandledAudioFormatException(inputAudioFormat);
}
active |= (channelIndex != i);
}
return active
? new AudioFormat(inputAudioFormat.sampleRate, outputChannels.length, C.ENCODING_PCM_16BIT)
: AudioFormat.NOT_SET;
}
@Override
public void queueInput(ByteBuffer inputBuffer) {
int[] outputChannels = Assertions.checkNotNull(this.outputChannels);View on GitHub (pinned to dd430f7053)
Solutions
- Clear the mapping when playing non-16-bit content: player.setAudioAttributes(...)/ DefaultAudioSink without setChannelMapping, or unset it via track selection parameters.
- Convert the stream to 16-bit PCM upstream (e.g. disable float output so the decoding chain outputs ENCODING_PCM_16BIT).
- Wrap sink configuration in try/catch for ConfigurationException/UnhandledAudioFormatException and rebuild the sink without channel mapping before retrying.
- Verify the media's actual PCM encoding via MediaFormat/Format before applying channel mapping.
Example fix
// before
AudioSink sink = new DefaultAudioSink.Builder(ctx)
.setChannelMapping(new int[] {0}) // force mono
.build();
// after — only map channels for 16-bit content
AudioSink.Builder builder = new DefaultAudioSink.Builder(ctx);
if (isPcm16BitContent) {
builder.setChannelMapping(new int[] {0});
}
AudioSink sink = builder.build(); Defensive patterns
Strategy: validation
Validate before calling
static int[] safeChannelMapping(int[] requested, @C.PcmEncoding int encoding,
int inputChannelCount) {
if (encoding != C.ENCODING_PCM_16BIT) return null; // processor inactive
int[] valid = new int[requested.length];
for (int i = 0; i < requested.length; i++) {
if (requested[i] >= inputChannelCount) return null; // would throw
valid[i] = requested[i];
}
return valid;
} Try / catch
try {
sinkBuilder.setChannelMapping(mapping).build();
} catch (Exception e) { // UnhandledAudioFormatException surfaces as ConfigurationException
sinkBuilder.setChannelMapping(null).build(); // rebuild without mapping
} Prevention
- Apply channel mapping only after confirming the decoded stream is 16-bit PCM
- Re-check encoding on every track change / playlist transition
- Clear mapping when switching to high-res or float content
When it happens
Trigger: Calling DefaultAudioSink.Builder.setChannelMapping(int[]) (directly or via DefaultTrackSelector parameters like setAudioChannelCountOverrides / ChannelMappingParameters) and then playing audio whose PCM encoding is 24-bit, 32-bit, or float rather than 16-bit.
Common situations: Apps using ChannelMappingAudioProcessor with high-resolution PCM streams; enabling audio offload or float output while channel mapping is set; forgetting to clear the mapping when switching between 16-bit and high-res content in a playlist.
Related errors
- Unhandled input format: {inputAudioFormat}
- Unhandled input format: {inputAudioFormat}
- Unhandled input format: {inputAudioFormat}
- Unhandled input format: ${audioFormat}
- Unhandled input format: {audioFormat}
AI-assisted analysis of google/ExoPlayer@dd430f7053 (2026-08-14).
Data as JSON: /api/errors/60c8fe6a8734ff64.
Report an issue: GitHub.