See the ExoPlayer supported formats page for an introduction to media formats in general. The same limitations on loading, extracting, and decoding streams apply with Transformer, though Transformer does not support ExoPlayer's bundled software decoder modules.
Transformer also relies on
MediaCodec for encoding, and needs to multiplex, or
mux, output media files, which limits the output formats supported. See
MediaCodec video codecs
for more information about encoding limitations and
for limitations that apply to the output media container. Transformer only
outputs MP4 files.
Transformer supports handling input in newer media formats that provide special features compared to conventional formats.
Handling HDR videos
More and more devices now support HDR video capture, giving more vivid, accurate colors and a greater brightness range.
Transformer supports editing HDR videos from Android 13 (API level 33) onwards
on devices with the required encoding support. When editing HDR videos, any GL
video effects need to handle 16-bit floating point color components and BT.2020
color space. To enable HDR editing, call
experimental_setEnableHdrEditing(true) on the
From Android 12 (API level 21) onwards,
MediaCodec supports converting HDR to
SDR, also known as tone-mapping, on some devices, including all Android 13+
devices that can capture HDR video. To enable tone-mapping call
setEnableRequestSdrToneMapping(true) on the
This is useful when sharing HDR media to other apps or services that don't
support ingestion of HDR content.
Handling slow motion media
Slow-motion videos include metadata indicating the speed at which each section of the stream should be played. Flattening is the process of producing a new video stream based on the slow-motion video but where the sections are sped up or slowed down based on metadata, so that they play correctly even on players that don't apply slow motion metadata.
To flatten slow-motion streams, use the
val transformer = Transformer.Builder(context) .setFlattenForSlowMotion(true) .setListener(transformerListener) .build() transformer.startTransformation(inputMediaItem, outputPath)
Transformer transformer = new Transformer.Builder(context) .setFlattenForSlowMotion(true) .setListener(transformerListener) .build(); transformer.startTransformation(inputMediaItem, outputPath);
This allows you to support slow-motion videos without having to worry about handling these special formats. All you need to do is to store and play the flattened version of the video instead of the original one.