Media3 Transformer 正在积极开发中,我们期待收到您的反馈意见!欢迎在
问题跟踪器中提供反馈、提交功能请求和错误报告。关注
ExoPlayer 博客,了解最新动态。
色调映射 - 支持 HDR 和 SDR 内容
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 Transformer 时,请务必考虑
HDR 和 SDR 内容之间的差距。HDR 显示的色彩细节更丰富,
颜色和对比度,为用户提供更好的视觉体验。但是,由于
HDR 和 SDR 之间的颜色范围差异,将这两种类型的
可能会导致兼容性问题。
在构建
Composition
,
您可以选择setHdrMode
。默认情况下,Transformer 会将此值设置为
HDR_MODE_KEEP_HDR
,
这可确保输出保持为 HDR 格式。如果设备未
支持 HDR 格式,Transformer 会自动尝试使用
HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL
。
在某些情况下,您可能会将 HDR 和 SDR 素材资源结合使用。例如,您
可能会在 HDR 视频和图片上叠加 SDR 叠加层,
HDR 和 SDR 视频在这种情况下,您可以采取以下做法:
|
优点 |
缺点 |
使用 MediaCodec 的色调映射 |
最佳视觉质量输出(如果设备和 API 组合支持的话)。 |
仅适用于特定设备上的 API 31 及更高版本,以及设备的 API 33 及更高版本
并支持 HDR 拍摄如果不受支持,Transformer 会抛出
ExportException 。 |
使用 OpenGL 设置色调地图 |
支持 API 29 及以上级别,跨设备的支持范围通常更广泛。产生更一致的结果。 |
与使用输出时相比,可能会产生轻微的差异
HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC 。 |
将 HDR 解释为 SDR |
支持最广泛的选项。 |
内容可能会呈现褪色效果,并且可能无法正常显示。 |
当前限制
多资产乐曲不支持以下内容:
- SDR 到 HDR 色调映射
- 以 HDR 资产开头的 SDR 和 HDR 内容序列
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Tone mapping - Supporting HDR and SDR content\n\nWhen working with Transformer, it is important to consider the compatibility\nbetween HDR and SDR content. HDR displays content with greater color detail,\ncolor and contrast, giving users a better visual experience. However, due to the\ndifference in color ranges between HDR and SDR, combining the two types of\ncontent could lead to compatibility issues.\n\nAs you are building a\n[`Composition`](/reference/androidx/media3/transformer/Composition.Builder),\nyou have the option to [`setHdrMode`](/reference/androidx/media3/transformer/Composition.Builder#setHdrMode(int))\nfor HDR video inputs. By default, Transformer sets this value to\n[`HDR_MODE_KEEP_HDR`](/reference/androidx/media3/transformer/Composition#HDR_MODE_KEEP_HDR()),\nwhich ensures the output is kept in the HDR format. If the device does not\nsupport the HDR format, Transformer automatically attempts to use\n[`HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL`](/reference/androidx/media3/transformer/Composition#HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL()) instead.\n\nIn some cases, you may be combining both HDR and SDR assets. For example, you\nmight have SDR overlays on top of HDR videos and images, or you might have a mix\nof HDR and SDR videos. In this case, you have the following options:\n\n| | Advantages | Disadvantages |\n|--------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Tone map with MediaCodec](/reference/androidx/media3/transformer/Composition#HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC()) | Best visual quality output if supported on device and API combination. | Only supported on API 31+ on certain devices and on API 33+ for devices with HDR capture support. If not supported, `Transformer` throws an `ExportException`. |\n| [Tone map with OpenGL](/reference/androidx/media3/transformer/Composition#HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL()) | Supported on API 29+, with generally wider support across devices. Produces more consistent results. | May produce mild differences compared to output from using `HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC`. |\n| [Interpret HDR as SDR](/reference/androidx/media3/transformer/Composition#HDR_MODE_EXPERIMENTAL_FORCE_INTERPRET_HDR_AS_SDR()) | Most widely supported option. | Contents will likely have a washed out look and may be displayed incorrectly. |\n\nCurrent limitations\n-------------------\n\nThe following are unsupported for multi-asset compositions:\n\n- SDR to HDR tone mapping\n- SDR and HDR content sequences that start with an HDR asset"]]