Add an analyzer mode option to Transformer demo.
PiperOrigin-RevId: 639746452
This commit is contained in:
parent
9ed86441e3
commit
304b784314
@ -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());
|
||||
|
@ -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. */
|
||||
|
@ -196,6 +196,16 @@
|
||||
android:layout_gravity="end"
|
||||
android:checked="true"/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/enable_analyzer_mode" />
|
||||
<CheckBox
|
||||
android:id="@+id/enable_analyzer_mode_checkbox"
|
||||
android:layout_gravity="end"
|
||||
android:checked="false"/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
|
@ -28,6 +28,7 @@
|
||||
<string name="scale" translatable="false">Scale video</string>
|
||||
<string name="rotate" translatable="false">Rotate video (degrees)</string>
|
||||
<string name="enable_fallback" translatable="false">Enable fallback</string>
|
||||
<string name="enable_analyzer_mode" translatable="false">Enable analyzer mode</string>
|
||||
<string name="enable_debug_preview" translatable="false">Enable debug preview</string>
|
||||
<string name="enable_debug_tracing" translatable="false">Enable debug tracing</string>
|
||||
<string name="abort_slow_export" translatable="false">Abort slow export</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user