Tunnel Mode Playback
The hardware decoder for some Fire TV devices supports playback of 4K @ 60 FPS. A video at this high resolution and frame rate creates aggressive timing requirements for the media pipeline. Due to kernel scheduling limitations, the app might not be able to render 4K frames at 16 msec interval. This limitation might 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
- More Details about Tunnel Mode Playback
- Limitations of Tunneled Mode
How to Enable Tunnel Mode Playback
The main changes required to enable Tunnel Mode playback are as follows:
-
Query the AudioTrack session ID from AudioManager:
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int audioSessionId = audioManager.generateAudioSessionId(); -
Configure Video Decoder for Tunnel mode:
format.setFeatureEnabled(MediaCodecInfo.CodecCapabilities.FEATURE_TunneledPlayback, true); -
Configure Video Decoder with the AudioTrack session ID.
format.setInteger(android.media.MediaFormat.KEY_AUDIO_SESSION_ID, audioSessionId); -
Create AudioTrack with the previously queried session ID and set the AudioAttributes flag
FLAG_HW_AV_SYNC.AudioAttributes attributes = new AudioAttributes.Builder() .setLegacyStreamType(AudioManager.STREAM_MUSIC) .setFlags(AudioAttributes.FLAG_HW_AV_SYNC) .build(); AudioFormat format = new AudioFormat.Builder() .setEncoding(targetEncoding) .setSampleRate(sampleRate) .setChannelMask(channelConfig) .build(); int mode = AudioTrack.MODE_STREAM; AudioTrack audioTrack = new AudioTrack(attributes, format, bufferSize, mode, audioSessionId); -
Do not call
dequeueOutputBufferandreleaseOutputBufferfor video decoder. -
AudioTrack provides a write API that automatically constructs 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:
- Enable tunneling end-to-end
- Support tunneling in video renderer
- Report tunneling support via RendererCapabilities API
- Plumbing to enable tunneling on AudioTrack from renderers
Limitations of Tunneled Mode
This Tunneled Mode playback information here applies to all Fire TV devices that run Fire OS 6 or later, with these constraints:
-
All Fire TV Streaming Media Players that run Fire OS 6 or later support tunneled mode for VP9 and HEVC decoders, with these limitations:
- For Fire TV Cube 2nd Gen (2019): Only secure decoders support tunneled mode, but applications can still use a secure decoder pipeline for clear content if they want to play clear content in tunneled mode. See secure decoder requirements.
-
All Fire TVs support tunnel mode for popular video codecs such as H.264, H.265, and VP9 for both secure and non-secure playback, with these limitations:
- Insignia HD - Fire TV (2018), Toshiba HD - Fire TV (2018), and Toshiba 4K - Fire TV (2018) do not support mono or multi channel PCM.
Last updated: May 29, 2026

