Media3 Transformer is actively under development and we are looking to hear from you! We welcome your feedback, feature requests and bug reports in the
issue tracker. Follow the
ExoPlayer blog for the latest updates.
Customization
Stay organized with collections
Save and categorize content based on your preferences.
To control Transformer's behavior, you can configure options in the API surface
or replace pieces of functionality completely by writing custom implementations
of interfaces and passing those in. This page describes some examples.
Control codec configuration
By default, Transformer will fall back to a supported resolution if the
device's hardware encoder doesn't accept the requested output resolution. For
example, Transformer can align the output width and height to be a multiple of 2
or 16 as is often required by hardware encoders. You can turn off this behavior
so that Transformer instead throws an error if it can't produce the required
output resolution:
Kotlin
transformerBuilder
.setEncoderFactory(
DefaultEncoderFactory.Builder(context)
.setEnableFallback(false)
.build())
Java
transformerBuilder
.setEncoderFactory(
new DefaultEncoderFactory.Builder(context)
.setEnableFallback(false)
.build());
Similarly, the DefaultEncoderFactory
also supports using custom encoding
settings with the setRequestedVideoEncoderSettings
option.
You can also completely replace the factories for encoders and decoders to get
full control over how the codecs are set up.
Custom muxers
You can set a custom muxer for writing media containers by calling
Transformer.setMuxerFactory
. For example, if you implement your own muxer at
the application level, you can write a wrapper that implements the Muxer
interface and then use setMuxerFactory
to inject it into Transformer.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-02-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-02-09 UTC."],[],[],null,["# Customization\n\nTo control Transformer's behavior, you can configure options in the API surface\nor replace pieces of functionality completely by writing custom implementations\nof interfaces and passing those in. This page describes some examples.\n\nControl codec configuration\n---------------------------\n\nBy default, Transformer will fall back to a supported resolution if the\ndevice's hardware encoder doesn't accept the requested output resolution. For\nexample, Transformer can align the output width and height to be a multiple of 2\nor 16 as is often required by hardware encoders. You can turn off this behavior\nso that Transformer instead throws an error if it can't produce the required\noutput resolution: \n\n### Kotlin\n\n```kotlin\ntransformerBuilder\n .setEncoderFactory(\n DefaultEncoderFactory.Builder(context)\n .setEnableFallback(false)\n .build())\n```\n\n### Java\n\n```java\ntransformerBuilder\n .setEncoderFactory(\n new DefaultEncoderFactory.Builder(context)\n .setEnableFallback(false)\n .build());\n```\n\n\u003cbr /\u003e\n\nSimilarly, the `DefaultEncoderFactory` also supports using custom encoding\nsettings with the `setRequestedVideoEncoderSettings` option.\n\nYou can also completely replace the factories for encoders and decoders to get\nfull control over how the codecs are set up.\n\nCustom muxers\n-------------\n\nYou can set a custom muxer for writing media containers by calling\n`Transformer.setMuxerFactory`. For example, if you implement your own muxer at\nthe application level, you can write a wrapper that implements the `Muxer`\ninterface and then use `setMuxerFactory` to inject it into Transformer."]]