Media3 Transformer 正在积极开发中,我们期待收到您的反馈意见!欢迎在
问题跟踪器中提供反馈、提交功能请求和错误报告。关注
ExoPlayer 博客,了解最新动态。
问题排查
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为什么我无法访问演示版应用中的本地文件?
从 Android 11 开始,分区存储强制执行
(API 级别 30)禁止直接访问文件系统。适合在运行过程中
可以通过将外部 API 的
存储权限:
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
然后通过 adb 授予权限:
adb shell appops set --uid androidx.media3.demo.transformer \
MANAGE_EXTERNAL_STORAGE allow
为什么在特定设备上导出操作失败?
请提交有关 Media3 问题
跟踪器。
以重现问题。可在以下位置添加针对设备特定问题的解决方法:
以便逐步提升兼容性。
Transformer 支持远程渐进式流,包括媒体文件容器
例如 MP4
在网络条件极差的情况下,由于正在缓冲,导出可能会失败
如果远程媒体时间过长,会在多路复用器中触发检查,
识别流水线卡住了您可以通过以下方法替换默认行为:
在 Transformer.Builder
上设置 maxDelayBetweenMuxerSamplesMs
:
Kotlin
Transformer.Builder(context)
.setMaxDelayBetweenMuxerSamplesMs(C.TIME_UNSET)
.build()
Java
new Transformer.Builder(context)
.setMaxDelayBetweenMuxerSamplesMs(C.TIME_UNSET)
.build();
传入 C.TIME_UNSET
会完全移除超时,但如果您的应用在
对于 MediaCodec
可能会卡住的芯片组,您可能需要设置一个更大的非零值
超时。
<ph type="x-smartling-placeholder">
Transformer 的实现方式与格式无关,因此没有
但设备上的硬件功能可能意味着
则导出操作失败。例如,即使在能够拍摄 8K 分辨率的设备上
由于超过 200 个参数,
可用的硬件编解码器或 RAM 资源。
Transformer 如何与平台兼容的媒体转码相关联?
兼容的媒体转码
是 Android 12(API 级别 31)中的一项 Android 平台功能,可将
将最长一分钟的媒体内容转换为应用支持的格式。如果您
选择启用这项功能,读取不兼容格式的媒体文件
会导致系统按需对其进行转码,并且将结果缓存起来以供日后读取
操作。
Transformer 还支持
转化,而
它作为支持库提供,并且应用可以完全控制
转码操作
如何缩短导出延迟时间或提高吞吐量?
Transformer 依赖 MediaCodec
进行硬件加速解码和
编码和 OpenGL 来处理视频帧。根据我们对
则 Transformer 吞吐量的限制因素是
MediaCodec
编码器吞吐量(适用于无重量级影响的用例)
处理。这可能会以同样的方式影响其他实现方式。对于
与平台兼容的转码功能的性能
Transformer。
演示版应用的调试预览会显著降低吞吐量,因此请关闭
在使用演示版应用的发布 build 进行测试时提供预览版功能,以获取
真实的想法和想法
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Troubleshooting\n\n- [Why can't I access local files in the demo app?](#local-files)\n- [Why does exporting fail on a specific device?](#device-specific)\n- [Does Transformer support transforming (or recording) remote media](#remote-media)\n- [Does Transformer support 8k input?](#8k-media)\n- [How does Transformer relate to platform compatible media transcoding?](#compatible-transcoding)\n- [How can I reduce export latency or increase throughput?](#throughput)\n\n*** ** * ** ***\n\n#### Why can't I access local files in the demo app?\n\n[Scoped storage enforcement](/about/versions/11/privacy/storage) from Android 11\n(API level 30) prevents direct file system access. For manual testing during\ndevelopment, it's possible to access local files by adding the manage external\nstorage permission in the demo app manifest: \n\n \u003cuses-permission android:name=\"android.permission.MANAGE_EXTERNAL_STORAGE\"/\u003e\n\nThen grant the permission via adb: \n\n```\nadb shell appops set --uid androidx.media3.demo.transformer \\\n MANAGE_EXTERNAL_STORAGE allow\n```\n\n#### Why does exporting fail on a specific device?\n\nPlease file an issue on the [Media3 issue\ntracker](https://github.com/androidx/media/issues) with enough information\nto reproduce the issue. Workarounds for device-specific issues can be added to\nthe library to improve compatibility over time.\n\n#### Does Transformer support transforming (or recording) remote media?\n\nTransformer supports remote progressive streams, including media file containers\nlike MP4.\n\nIn very poor network conditions, exporting may fail because buffering\nremote media for too long triggers checks in the muxer that are intended to\nidentify that the pipeline is stuck. You can override the default behavior by\nsetting `maxDelayBetweenMuxerSamplesMs` on `Transformer.Builder`: \n\n### Kotlin\n\n```kotlin\nTransformer.Builder(context)\n .setMaxDelayBetweenMuxerSamplesMs(C.TIME_UNSET)\n .build()\n```\n\n### Java\n\n```java\nnew Transformer.Builder(context)\n .setMaxDelayBetweenMuxerSamplesMs(C.TIME_UNSET)\n .build();\n```\n\n\u003cbr /\u003e\n\nPassing in `C.TIME_UNSET` removes the timeout entirely, but if your app runs on\nchipsets where `MediaCodec` can get stuck you may want to set a larger non-zero\ntimeout.\n| **[Known Issue #10943:](https://github.com/google/ExoPlayer/issues/10943)** Feature request to officially support transforming remote live streams with unknown duration using protocols like DASH and HLS.\n\n#### Does Transformer support 8k input?\n\nTransformer is implemented in a format-agnostic way, so it doesn't limit\nhandling of 8k video, but hardware capabilities on the device may mean that\nexporting can't succeed. For example, even on devices that can capture 8k,\nit might not be possible to decode and re-encode an 8k video due to exceeding\nthe available hardware codec or RAM resources.\n\n#### How does Transformer relate to platform compatible media transcoding?\n\n[Compatible media transcoding](/guide/topics/media-apps/video-app/compatible-media-transcoding)\nis an Android platform feature from Android 12 (API level 31) that converts\nmedia up to one minute in length into formats supported by the app. If you\nopt-in to using this feature, reading a media file in an incompatible format\ncauses it to be transcoded on demand, and the result is cached for later read\noperations.\n\nTransformer also supports [format\nconversion](/guide/topics/media/transformer/transformations?#transcode), but\nit's available as a support library and the app has full control over the\ntranscoding operation.\n\n#### How can I reduce export latency or increase throughput?\n\nTransformer relies on `MediaCodec` for hardware-accelerated decoding and\nencoding, and OpenGL for processing video frames. Based on our measurements on\ntypical devices, the limiting factor in Transformer's throughput is hardware\n`MediaCodec` encoder throughput for use cases without heavyweight effects\nprocessing. This is likely to impact other implementations in the same way. For\nexample, the platform compatible transcoding feature has similar performance to\nTransformer.\n\nThe demo app's debug preview significantly reduces throughput, so turn off the\npreview feature when testing with a release build of the demo app to get a\nrealistic idea of performance."]]