Developer Console
Vielen Dank für deinen Besuch. Diese Seite ist nur in Englisch verfügbar.

Tunnel Mode Playback

The hardware decoder for some Fire TV devices support playback of 4K @ 60 FPS. To play a video at such high resolution and frame rate, the timing requirement of media pipeline is very aggressive and the app may not be able to render 4K frames at 16 msec interval due to thread and process scheduling limitations of the kernel. This may cause frame drops and a sub-par movie experience. To get the best out of the hardware, use Tunnel Mode playback.

How to Enable Tunnel Mode Playback

The main changes required to enable Tunnel Mode playback are as follows:

  1. Query the AudioTrack session ID from AudioManager:

    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    int audioSessionId = audioManager.generateAudioSessionId();
  2. Configure Video Decoder for Tunnel mode:

    format.setFeatureEnabled(MediaCodecInfo.CodecCapabilities.FEATURE_TunneledPlayback, true);
  3. Configure Video decoder with the AudioTrack session ID.

    format.setInteger(, audioSessionId);
  4. Create AudioTrack with the above queried session ID and set the AudioAttributes flag FLAG_HW_AV_SYNC.

    AudioAttributes attributes = new AudioAttributes.Builder()
     AudioFormat format = new AudioFormat.Builder()
     int mode = AudioTrack.MODE_STREAM;
     AudioTrack audioTrack = new AudioTrack(attributes, format, bufferSize, mode, audioSessionId);
  5. Do not call dequeueOutputBuffer and releaseOutputBuffer for video decoder.

  6. AudioTrack provides a write API that will automatically construct the additional header information. For details see here.

    Note: The additional parameter is the timestamp that corresponds with the data being written.

More Details about Tunnel Mode Playback

For more details refer to the Tunnel Mode Playback implementation in Exoplayer 2:

Limitations of Tunneled Mode

The information about Tunneled Mode playback in this document applies to all Fire TV devices running on Fire OS 6 or later with the following constraints:

  • All FireTV Streaming Media Players running Fire OS 6 or later support tunneled mode for VP9 and HEVC decoders with the following limitations:

    • For Fire TV Cube 2nd Gen (2019): Tunneled mode is only supported by the secure decoders, but applications can still use a secure decoder pipeline for clear content if they wish to play clear content in tunneled mode. See secure decoder requirements.
  • All Fire TVs support tunnel mode for popular video codecs such as h264, h265, and VP9 for both secure and non-secure playback with the following limitations:

Last updated: Jun 03, 2021