google/ExoPlayer · error · MediaCodecRenderer.DecoderInitializationException

DECODER_QUERY_ERROR

DECODER_QUERY_ERROR

Error message

Decoder init failed: [{errorCode}], {format}

What it means

MediaCodecRenderer.getCodecInfos() queries the device codec list (MediaCodecUtil.getCodecInfos) to find decoders matching the input format; if that query itself fails, a DecoderQueryException is raised and wrapped in DecoderInitializationException with code DECODER_QUERY_ERROR. The failure is not 'no decoder exists' but 'the codec database could not be queried' — the original cause (chained via DecoderInitializationException.getCause) explains what broke, typically an OEM codec entry that crashed enumeration or a framework MediaCodecList error.

Source

Thrown at library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java:1018

    return false;
  }

  private void maybeInitCodecWithFallback(
      @Nullable MediaCrypto crypto, boolean mediaCryptoRequiresSecureDecoder)
      throws DecoderInitializationException {
    if (availableCodecInfos == null) {
      try {
        List<MediaCodecInfo> allAvailableCodecInfos =
            getAvailableCodecInfos(mediaCryptoRequiresSecureDecoder);
        availableCodecInfos = new ArrayDeque<>();
        if (enableDecoderFallback) {
          availableCodecInfos.addAll(allAvailableCodecInfos);
        } else if (!allAvailableCodecInfos.isEmpty()) {
          availableCodecInfos.add(allAvailableCodecInfos.get(0));
        }
        preferredDecoderInitializationException = null;
      } catch (DecoderQueryException e) {
        throw new DecoderInitializationException(
            inputFormat,
            e,
            mediaCryptoRequiresSecureDecoder,
            DecoderInitializationException.DECODER_QUERY_ERROR);
      }
    }

    if (availableCodecInfos.isEmpty()) {
      throw new DecoderInitializationException(
          inputFormat,
          /* cause= */ null,
          mediaCryptoRequiresSecureDecoder,
          DecoderInitializationException.NO_SUITABLE_DECODER_ERROR);
    }

    MediaCodecInfo preferredCodecInfo = availableCodecInfos.peekFirst();
    while (codec == null) {
      MediaCodecInfo codecInfo = availableCodecInfos.peekFirst();

View on GitHub (pinned to dd430f7053)

Solutions

  1. Upgrade ExoPlayer (MediaCodecUtil enumeration robustness is improved across releases) — many DecoderQueryException classes of failure are fixed in newer versions.
  2. Inspect the cause: catch DecoderInitializationException and log getCause() to identify the offending codec/vendor error before changing anything else.
  3. Reproduce on the affected device and check for vendor system updates; a broken codec list is a firmware defect.
  4. If the device is known-bad, route those users to a software-decoder route (FFmpeg extension MediaCodecAudio/VideoRenderer alternatives) or an alternative stream profile as a fallback.

Example fix

// before
player.addAnalyticsListener(new AnalyticsListener() {}); // no handling: crash surfaces as generic playback error

// after
@Override
public void onPlayerError(PlaybackException error) {
  Throwable cause = error.getCause();
  if (cause instanceof DecoderInitializationException
      && ((DecoderInitializationException) cause).decoderName == null
      && cause.getCause() instanceof DecoderQueryException) {
    // codec enumeration failed on this device: report model + cause, switch fallback stream
    logDecoderQueryFailure(Build.MODEL, cause.getCause());
  }
}
Defensive patterns

Strategy: try-catch

Try / catch

@Override
public void onPlayerError(PlaybackException error) {
  if (error.errorCode == PlaybackException.ERROR_CODE_DECODER_INIT_FAILED
      && error.getCause() instanceof DecoderInitializationException) {
    DecoderInitializationException die = (DecoderInitializationException) error.getCause();
    if (die.getCause() instanceof DecoderQueryException) {
      // codec enumeration failed on this device: log Build.MODEL + cause, offer fallback rendition
    }
  }
}

Prevention

When it happens

Trigger: Renderer initialization (onInputFormatChanged -> maybeInitCodec path) on devices where MediaCodecUtil's codec enumeration throws: malformed codec names/capabilities reported by the vendor, NoSuchMethodException/IllegalStateException while reflecting codec capabilities, or a transient MediaCodecList failure; happens for any MIME query (video/audio) right at stream start.

Common situations: Specific OEM Android builds with broken codec metadata (common on low-end/older devices and some smart-TV forks); Android version upgrades exposing new capability fields that old ExoPlayer versions cannot parse; crashes reported only on a narrow device matrix; content plays on most devices but fails on one model.

Related errors


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