Media3 Transformer 正在积极开发中,我们期待收到您的反馈意见!欢迎在
问题跟踪器中提供反馈、提交功能请求和错误报告。关注
ExoPlayer 博客,了解最新动态。
支持的格式
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
请参阅 ExoPlayer 支持的格式
页面
各种媒体格式在加载、提取和加载
解码流适用于 Transformer,但 Transformer 不支持
ExoPlayer 的捆绑软件解码器模块。
Transformer 还依赖于 MediaCodec
进行编码,并且需要复用,或者
mux,输出媒体文件,限制支持的输出格式。请参阅
MediaCodec 视频编解码器
以便详细了解编码限制和
MediaMuxer
了解适用于输出媒体容器的限制。仅限 Transformer
可输出 MP4 文件。
默认情况下,Transformer
使用 MediaMuxer
,但正在进行中的 InAppMuxer
可以选择性提供,以避免 MediaMuxer
在
参考帧结构和支持的样本格式。默认多路复用器
成为应用内多路复用器。
图片支持
Transformer 使用 BitmapFactory
加载和解码所有图片资源,
Transformer 支持 BitmapFactory 支持的所有格式。请参阅
图片支持
了解受支持的图片类型对于多图格式(例如 GIF),单张图片
如果 DefaultAssetLoaderFactory
,则会显示容器中的帧。
。
Transformer 支持处理较新的媒体格式中的输入,
功能。
处理 HDR 视频
越来越多的设备现在支持HDR 视频
拍摄,让照片更生动、更准确
更大的亮度范围。
Transformer 支持编辑 Android 13(API 级别 33)及更高版本的 HDR 视频
。编辑 HDR 视频时,任何 GL
视频特效需要处理 16 位浮点颜色组件和 BT.2020
颜色空间。HDR_MODE_KEEP_HDR
是构建
Composition
。如果不支持 HDR 编辑,则 Transformer
回退到使用 HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL
。
Android 支持将 HDR 转换为 SDR(也称为色调映射)
在具有所需解码和 OpenGL 的设备上,从 10(API 级别 29)开始
联系。这对于将 HDR 媒体分享到
不支持提取 HDR 内容。使用 OpenGL 调用启用色调映射
setHdrMode(HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL)
(在创建
Composition
。从 Android 12(API 级别 31)开始,MediaCodec
还支持在某些设备上进行色调映射,包括所有
可拍摄 HDR 视频的 Android 13 或更高版本。如需启用色调映射,请使用
MediaCodec
调用 setHdrMode(HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC)
。
处理慢动作媒体
慢动作视频包含元数据,用于指明各个部分的播放速度
音频流。扁平化是
基于慢动作视频但各个部分加速的视频
根据元数据判断播放速度变慢,这样,即使是在播放器中,也能够正常播放
不应用慢动作元数据的那些视频
如需展平慢动作流,请使用 setFlattenForSlowMotion
构建器
方法。EditedMediaItem
Kotlin
val editedMediaItem =
EditedMediaItem.Builder(inputMediaItem).setFlattenForSlowMotion(true).build()
val transformer =
Transformer.Builder(context).addListener(transformerListener).build()
transformer.start(editedMediaItem, outputPath)
Java
EditedMediaItem editedMediaItem =
new EditedMediaItem.Builder(inputMediaItem).setFlattenForSlowMotion(true).build();
Transformer transformer =
new Transformer.Builder(context).addListener(transformerListener).build();
transformer.start(editedMediaItem, outputPath);
这样你就可以支持慢动作视频,无需担心
处理这些特殊格式。你只需存储和播放
视频的扁平版本,而不是原始版本。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):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."]]