diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/ConfigurationActivity.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/ConfigurationActivity.java
index 9ad61b99ac..363e6f2ed1 100644
--- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/ConfigurationActivity.java
+++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/ConfigurationActivity.java
@@ -77,6 +77,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
public static final String TRIM_START_MS = "trim_start_ms";
public static final String TRIM_END_MS = "trim_end_ms";
public static final String ENABLE_FALLBACK = "enable_fallback";
+ public static final String ENABLE_ANALYZER_MODE = "enable_analyzer_mode";
public static final String ENABLE_DEBUG_PREVIEW = "enable_debug_preview";
public static final String ABORT_SLOW_EXPORT = "abort_slow_export";
public static final String PRODUCE_FRAGMENTED_MP4 = "produce_fragmented_mp4";
@@ -170,6 +171,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
private @MonotonicNonNull Spinner rotateSpinner;
private @MonotonicNonNull CheckBox trimCheckBox;
private @MonotonicNonNull CheckBox enableFallbackCheckBox;
+ private @MonotonicNonNull CheckBox enableAnalyzerModeCheckBox;
private @MonotonicNonNull CheckBox enableDebugPreviewCheckBox;
private @MonotonicNonNull CheckBox enableDebugTracingCheckBox;
private @MonotonicNonNull CheckBox abortSlowExportCheckBox;
@@ -292,6 +294,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
trimEndMs = C.TIME_UNSET;
enableFallbackCheckBox = findViewById(R.id.enable_fallback_checkbox);
+ enableAnalyzerModeCheckBox = findViewById(R.id.enable_analyzer_mode_checkbox);
enableDebugPreviewCheckBox = findViewById(R.id.enable_debug_preview_checkbox);
enableDebugTracingCheckBox = findViewById(R.id.enable_debug_tracing_checkbox);
enableDebugTracingCheckBox.setOnCheckedChangeListener(
@@ -365,6 +368,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
"rotateSpinner",
"trimCheckBox",
"enableFallbackCheckBox",
+ "enableAnalyzerModeCheckBox",
"enableDebugPreviewCheckBox",
"abortSlowExportCheckBox",
"produceFragmentedMp4CheckBox",
@@ -407,6 +411,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
bundle.putLong(TRIM_END_MS, trimEndMs);
}
bundle.putBoolean(ENABLE_FALLBACK, enableFallbackCheckBox.isChecked());
+ bundle.putBoolean(ENABLE_ANALYZER_MODE, enableAnalyzerModeCheckBox.isChecked());
bundle.putBoolean(ENABLE_DEBUG_PREVIEW, enableDebugPreviewCheckBox.isChecked());
bundle.putBoolean(ABORT_SLOW_EXPORT, abortSlowExportCheckBox.isChecked());
bundle.putBoolean(PRODUCE_FRAGMENTED_MP4, produceFragmentedMp4CheckBox.isChecked());
diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
index 0ef03f7602..2297e05451 100644
--- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
+++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
@@ -87,6 +87,7 @@ import androidx.media3.transformer.DefaultMuxer;
import androidx.media3.transformer.EditedMediaItem;
import androidx.media3.transformer.EditedMediaItemSequence;
import androidx.media3.transformer.Effects;
+import androidx.media3.transformer.ExperimentalAnalyzerModeFactory;
import androidx.media3.transformer.ExportException;
import androidx.media3.transformer.ExportResult;
import androidx.media3.transformer.InAppMuxer;
@@ -310,7 +311,24 @@ public final class TransformerActivity extends AppCompatActivity {
"debugFrame",
})
private Transformer createTransformer(@Nullable Bundle bundle, Uri inputUri, String filePath) {
- Transformer.Builder transformerBuilder = new Transformer.Builder(/* context= */ this);
+ Transformer.Builder transformerBuilder =
+ new Transformer.Builder(/* context= */ this)
+ .addListener(
+ new Transformer.Listener() {
+ @Override
+ public void onCompleted(Composition composition, ExportResult exportResult) {
+ TransformerActivity.this.onCompleted(inputUri, filePath, exportResult);
+ }
+
+ @Override
+ public void onError(
+ Composition composition,
+ ExportResult exportResult,
+ ExportException exportException) {
+ TransformerActivity.this.onError(exportException);
+ }
+ });
+
if (bundle != null) {
@Nullable String audioMimeType = bundle.getString(ConfigurationActivity.AUDIO_MIME_TYPE);
if (audioMimeType != null) {
@@ -339,25 +357,14 @@ public final class TransformerActivity extends AppCompatActivity {
if (bundle.getBoolean(ConfigurationActivity.ENABLE_DEBUG_PREVIEW)) {
transformerBuilder.setDebugViewProvider(new DemoDebugViewProvider());
}
+
+ if (bundle.getBoolean(ConfigurationActivity.ENABLE_ANALYZER_MODE)) {
+ return ExperimentalAnalyzerModeFactory.buildAnalyzer(
+ this.getApplicationContext(), transformerBuilder.build());
+ }
}
- return transformerBuilder
- .addListener(
- new Transformer.Listener() {
- @Override
- public void onCompleted(Composition composition, ExportResult exportResult) {
- TransformerActivity.this.onCompleted(inputUri, filePath, exportResult);
- }
-
- @Override
- public void onError(
- Composition composition,
- ExportResult exportResult,
- ExportException exportException) {
- TransformerActivity.this.onError(exportException);
- }
- })
- .build();
+ return transformerBuilder.build();
}
/** Creates a cache file, resetting it if it already exists. */
diff --git a/demos/transformer/src/main/res/layout/configuration_activity.xml b/demos/transformer/src/main/res/layout/configuration_activity.xml
index 62be3f3349..3c5bee54bf 100644
--- a/demos/transformer/src/main/res/layout/configuration_activity.xml
+++ b/demos/transformer/src/main/res/layout/configuration_activity.xml
@@ -196,6 +196,16 @@
android:layout_gravity="end"
android:checked="true"/>
+
+
+
+
Scale video
Rotate video (degrees)
Enable fallback
+ Enable analyzer mode
Enable debug preview
Enable debug tracing
Abort slow export