カスタマイズ
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Transformer の動作を制御するには、API サーフェスでオプションを構成します。
または、カスタム実装を記述して機能の一部を完全に置き換えます。
渡すだけではありませんこのページでは、いくつかの例について説明します。
コーデックの設定を制御する
デフォルトでは、Transformer は、
デバイスのハードウェア エンコーダが、要求された出力解像度を受け入れません。対象
たとえば、出力の幅と高さが 2 の倍数になるように調整できます。
16 に設定することもできます。この動作はオフにできます。
必要な変換を生成できない場合、Transformer は代わりにエラーをスローするようにします。
出力解像度:
Kotlin
transformerBuilder
.setEncoderFactory(
DefaultEncoderFactory.Builder(context)
.setEnableFallback(false)
.build())
Java
transformerBuilder
.setEncoderFactory(
new DefaultEncoderFactory.Builder(context)
.setEnableFallback(false)
.build());
同様に、DefaultEncoderFactory
はカスタム エンコードの使用もサポートしています。
setRequestedVideoEncoderSettings
オプションを使用します。
また、エンコーダとデコーダのファクトリを完全に置き換えて、
コーデックの設定方法を完全に制御できます。
カスタム マルチプレクサ
次の呼び出しによって、メディア コンテナを書き込むためのカスタム マルチプレクサを設定できます。
Transformer.setMuxerFactory
。たとえば、独自のマルチプレクサを
アプリレベルでは、Muxer
を実装するラッパーを記述し、
setMuxerFactory
を使用して Transformer に挿入します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","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 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."]]