[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Supported formats\n\nSee the [ExoPlayer supported formats\npage](/guide/topics/media/exoplayer/media-items) for an introduction to\nmedia formats in general. The same limitations on loading, extracting, and\ndecoding streams apply with Transformer, though Transformer does not support\nExoPlayer's bundled software decoder modules.\n\nTransformer also relies on `MediaCodec` for encoding, and needs to multiplex, or\n*mux* , output media files, which limits the output formats supported. See\n[MediaCodec video codecs](https://developer.android.com/guide/topics/media/media-formats#video-codecs)\nfor more information about encoding limitations and\n[MediaMuxer](https://developer.android.com/reference/android/media/MediaMuxer)\nfor limitations that apply to the output media container. Transformer only\noutputs MP4 files.\n\nBy default, `Transformer` uses `MediaMuxer`, but a work-in-progress `InAppMuxer`\nis optionally available to avoid some of `MediaMuxer`'s limitations around\nreference frame structures and supported sample formats. The default muxer will\nbecome the in-app muxer in a future release.\n\nImage support\n-------------\n\nTransformer uses `BitmapFactory` to load and decode all image assets, so\nTransformer supports all the formats BitmapFactory does. See\n[Image support](/guide/topics/media/media-formats#image-formats)\nfor supported image types. For multi-picture formats (e.g. gifs), a single image\nframe from the container is displayed if the `DefaultAssetLoaderFactory` is\nused.\n\nSpecial formats\n---------------\n\nTransformer supports handling input in newer media formats that provide special\nfeatures compared to conventional formats.\n\n### Handling HDR videos\n\nMore and more devices now support [HDR video\ncapture](/training/camera2/hdr-video-capture), giving more vivid, accurate\ncolors and a greater brightness range.\n\nTransformer supports editing HDR videos from Android 13 (API level 33) onwards\non devices with the required encoding support. When editing HDR videos, any GL\nvideo effects need to handle 16-bit floating point color components and BT.2020\ncolor space. `HDR_MODE_KEEP_HDR` is the default mode when building the\n`Composition`. If HDR editing is not supported, the Transformer\nfalls back to using `HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL`.\n\nConverting HDR to SDR, also known as *tone-mapping* , is supported from Android\n10 (API level 29) onwards on devices with the required decoding and OpenGL\nsupport. This is useful when sharing HDR media to other apps or services that\ndon't support ingestion of HDR content. To enable tone-mapping using OpenGL call\n`setHdrMode(HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL)` when creating the\n`Composition`. From Android 12 (API level 31) onwards, `MediaCodec`\nalso supports tone-mapping on some devices, including all devices running\nAndroid 13 or higher that can capture HDR video. To enable tone-mapping using\n`MediaCodec` call `setHdrMode(HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC)`.\n\n### Handling slow motion media\n\nSlow-motion videos include metadata indicating the speed at which each section\nof the stream should be played. *Flattening* is the process of producing a new\nvideo stream based on the slow-motion video but where the sections are sped up\nor slowed down based on metadata, so that they play correctly even on players\nthat don't apply slow motion metadata.\n\nTo flatten slow-motion streams, use the `setFlattenForSlowMotion` builder\nmethod on `EditedMediaItem`. \n\n### Kotlin\n\n```kotlin\nval editedMediaItem =\n EditedMediaItem.Builder(inputMediaItem).setFlattenForSlowMotion(true).build()\nval transformer =\n Transformer.Builder(context).addListener(transformerListener).build()\ntransformer.start(editedMediaItem, outputPath)\n```\n\n### Java\n\n```java\nEditedMediaItem editedMediaItem =\n new EditedMediaItem.Builder(inputMediaItem).setFlattenForSlowMotion(true).build();\nTransformer transformer =\n new Transformer.Builder(context).addListener(transformerListener).build();\ntransformer.start(editedMediaItem, outputPath);\n```\n\n\u003cbr /\u003e\n\nThis allows you to support slow-motion videos without having to worry about\nhandling these special formats. All you need to do is to store and play the\nflattened version of the video instead of the original one.\n| **Note:** Only Samsung's slow motion format is supported."]]