diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TranscodingTransformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TranscodingTransformer.java
index f04a11d094..643705c00d 100644
--- a/libraries/transformer/src/main/java/androidx/media3/transformer/TranscodingTransformer.java
+++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TranscodingTransformer.java
@@ -102,7 +102,7 @@ public final class TranscodingTransformer {
private boolean removeVideo;
private boolean flattenForSlowMotion;
private int outputHeight;
- private String outputMimeType;
+ private String containerMimeType;
@Nullable private String audioMimeType;
@Nullable private String videoMimeType;
private TranscodingTransformer.Listener listener;
@@ -113,7 +113,7 @@ public final class TranscodingTransformer {
public Builder() {
muxerFactory = new FrameworkMuxer.Factory();
outputHeight = Transformation.NO_VALUE;
- outputMimeType = MimeTypes.VIDEO_MP4;
+ containerMimeType = MimeTypes.VIDEO_MP4;
listener = new Listener() {};
looper = Util.getCurrentOrMainLooper();
clock = Clock.DEFAULT;
@@ -128,7 +128,7 @@ public final class TranscodingTransformer {
this.removeVideo = transcodingTransformer.transformation.removeVideo;
this.flattenForSlowMotion = transcodingTransformer.transformation.flattenForSlowMotion;
this.outputHeight = transcodingTransformer.transformation.outputHeight;
- this.outputMimeType = transcodingTransformer.transformation.outputMimeType;
+ this.containerMimeType = transcodingTransformer.transformation.containerMimeType;
this.audioMimeType = transcodingTransformer.transformation.audioMimeType;
this.videoMimeType = transcodingTransformer.transformation.videoMimeType;
this.listener = transcodingTransformer.listener;
@@ -260,11 +260,30 @@ public final class TranscodingTransformer {
*
{@link MimeTypes#VIDEO_WEBM} from API level 21
*
*
- * @param outputMimeType The MIME type of the output.
+ * @param outputMimeType The MIME type of the container.
+ * @return This builder.
+ * @deprecated Use {@link #setContainerMimeType} instead.
+ */
+ @Deprecated
+ public Builder setOutputMimeType(String outputMimeType) {
+ this.containerMimeType = outputMimeType;
+ return this;
+ }
+
+ /**
+ * Sets the MIME type of the output container. The default value is {@link MimeTypes#VIDEO_MP4}.
+ * Supported values are:
+ *
+ *
+ * - {@link MimeTypes#VIDEO_MP4}
+ *
- {@link MimeTypes#VIDEO_WEBM} from API level 21
+ *
+ *
+ * @param containerMimeType The MIME type of the container.
* @return This builder.
*/
- public Builder setOutputMimeType(String outputMimeType) {
- this.outputMimeType = outputMimeType;
+ public Builder setContainerMimeType(String containerMimeType) {
+ this.containerMimeType = containerMimeType;
return this;
}
@@ -379,7 +398,7 @@ public final class TranscodingTransformer {
* @throws IllegalStateException If the {@link Context} has not been provided.
* @throws IllegalStateException If both audio and video have been removed (otherwise the output
* would not contain any samples).
- * @throws IllegalStateException If the muxer doesn't support the requested output MIME type.
+ * @throws IllegalStateException If the muxer doesn't support the requested container MIME type.
* @throws IllegalStateException If the muxer doesn't support the requested audio MIME type.
*/
public TranscodingTransformer build() {
@@ -392,8 +411,8 @@ public final class TranscodingTransformer {
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
}
checkState(
- muxerFactory.supportsOutputMimeType(outputMimeType),
- "Unsupported output MIME type: " + outputMimeType);
+ muxerFactory.supportsOutputMimeType(containerMimeType),
+ "Unsupported container MIME type: " + containerMimeType);
if (audioMimeType != null) {
checkSampleMimeType(audioMimeType);
}
@@ -406,7 +425,7 @@ public final class TranscodingTransformer {
removeVideo,
flattenForSlowMotion,
outputHeight,
- outputMimeType,
+ containerMimeType,
audioMimeType,
videoMimeType);
return new TranscodingTransformer(
@@ -415,11 +434,11 @@ public final class TranscodingTransformer {
private void checkSampleMimeType(String sampleMimeType) {
checkState(
- muxerFactory.supportsSampleMimeType(sampleMimeType, outputMimeType),
+ muxerFactory.supportsSampleMimeType(sampleMimeType, containerMimeType),
"Unsupported sample MIME type "
+ sampleMimeType
+ " for container MIME type "
- + outputMimeType);
+ + containerMimeType);
}
}
@@ -542,7 +561,7 @@ public final class TranscodingTransformer {
* @throws IOException If an error occurs opening the output file for writing.
*/
public void startTransformation(MediaItem mediaItem, String path) throws IOException {
- startTransformation(mediaItem, muxerFactory.create(path, transformation.outputMimeType));
+ startTransformation(mediaItem, muxerFactory.create(path, transformation.containerMimeType));
}
/**
@@ -573,7 +592,7 @@ public final class TranscodingTransformer {
public void startTransformation(MediaItem mediaItem, ParcelFileDescriptor parcelFileDescriptor)
throws IOException {
startTransformation(
- mediaItem, muxerFactory.create(parcelFileDescriptor, transformation.outputMimeType));
+ mediaItem, muxerFactory.create(parcelFileDescriptor, transformation.containerMimeType));
}
private void startTransformation(MediaItem mediaItem, Muxer muxer) {
@@ -583,7 +602,7 @@ public final class TranscodingTransformer {
}
MuxerWrapper muxerWrapper =
- new MuxerWrapper(muxer, muxerFactory, transformation.outputMimeType);
+ new MuxerWrapper(muxer, muxerFactory, transformation.containerMimeType);
this.muxerWrapper = muxerWrapper;
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
trackSelector.setParameters(
diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java
index a3f3343281..d688e04acf 100644
--- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java
+++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformation.java
@@ -28,7 +28,7 @@ import androidx.annotation.Nullable;
public final boolean removeVideo;
public final boolean flattenForSlowMotion;
public final int outputHeight;
- public final String outputMimeType;
+ public final String containerMimeType;
@Nullable public final String audioMimeType;
@Nullable public final String videoMimeType;
@@ -37,14 +37,14 @@ import androidx.annotation.Nullable;
boolean removeVideo,
boolean flattenForSlowMotion,
int outputHeight,
- String outputMimeType,
+ String containerMimeType,
@Nullable String audioMimeType,
@Nullable String videoMimeType) {
this.removeAudio = removeAudio;
this.removeVideo = removeVideo;
this.flattenForSlowMotion = flattenForSlowMotion;
this.outputHeight = outputHeight;
- this.outputMimeType = outputMimeType;
+ this.containerMimeType = containerMimeType;
this.audioMimeType = audioMimeType;
this.videoMimeType = videoMimeType;
}
diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
index 89ac90df38..74c9a0e0c0 100644
--- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
+++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
@@ -97,7 +97,7 @@ public final class Transformer {
private boolean removeAudio;
private boolean removeVideo;
private boolean flattenForSlowMotion;
- private String outputMimeType;
+ private String containerMimeType;
private Transformer.Listener listener;
private Looper looper;
private Clock clock;
@@ -105,7 +105,7 @@ public final class Transformer {
/** Creates a builder with default values. */
public Builder() {
muxerFactory = new FrameworkMuxer.Factory();
- outputMimeType = MimeTypes.VIDEO_MP4;
+ containerMimeType = MimeTypes.VIDEO_MP4;
listener = new Listener() {};
looper = Util.getCurrentOrMainLooper();
clock = Clock.DEFAULT;
@@ -119,7 +119,7 @@ public final class Transformer {
this.removeAudio = transformer.transformation.removeAudio;
this.removeVideo = transformer.transformation.removeVideo;
this.flattenForSlowMotion = transformer.transformation.flattenForSlowMotion;
- this.outputMimeType = transformer.transformation.outputMimeType;
+ this.containerMimeType = transformer.transformation.containerMimeType;
this.listener = transformer.listener;
this.looper = transformer.looper;
this.clock = transformer.clock;
@@ -218,11 +218,30 @@ public final class Transformer {
* {@link MimeTypes#VIDEO_WEBM} from API level 21
*
*
- * @param outputMimeType The MIME type of the output.
+ * @param outputMimeType The MIME type of the container.
+ * @return This builder.
+ * @deprecated Use {@link #setContainerMimeType} instead.
+ */
+ @Deprecated
+ public Builder setOutputMimeType(String outputMimeType) {
+ this.containerMimeType = outputMimeType;
+ return this;
+ }
+
+ /**
+ * Sets the MIME type of the output container. The default value is {@link MimeTypes#VIDEO_MP4}.
+ * Supported values are:
+ *
+ *
+ * - {@link MimeTypes#VIDEO_MP4}
+ *
- {@link MimeTypes#VIDEO_WEBM} from API level 21
+ *
+ *
+ * @param containerMimeType The MIME type of the output.
* @return This builder.
*/
- public Builder setOutputMimeType(String outputMimeType) {
- this.outputMimeType = outputMimeType;
+ public Builder setContainerMimeType(String containerMimeType) {
+ this.containerMimeType = containerMimeType;
return this;
}
@@ -285,7 +304,7 @@ public final class Transformer {
* @throws IllegalStateException If the {@link Context} has not been provided.
* @throws IllegalStateException If both audio and video have been removed (otherwise the output
* would not contain any samples).
- * @throws IllegalStateException If the muxer doesn't support the requested output MIME type.
+ * @throws IllegalStateException If the muxer doesn't support the requested container MIME type.
*/
public Transformer build() {
checkStateNotNull(context);
@@ -297,15 +316,15 @@ public final class Transformer {
mediaSourceFactory = new DefaultMediaSourceFactory(context, defaultExtractorsFactory);
}
checkState(
- muxerFactory.supportsOutputMimeType(outputMimeType),
- "Unsupported output MIME type: " + outputMimeType);
+ muxerFactory.supportsOutputMimeType(containerMimeType),
+ "Unsupported container MIME type: " + containerMimeType);
Transformation transformation =
new Transformation(
removeAudio,
removeVideo,
flattenForSlowMotion,
/* outputHeight= */ Transformation.NO_VALUE,
- outputMimeType,
+ containerMimeType,
/* audioMimeType= */ null,
/* videoMimeType= */ null);
return new Transformer(
@@ -430,7 +449,7 @@ public final class Transformer {
* @throws IOException If an error occurs opening the output file for writing.
*/
public void startTransformation(MediaItem mediaItem, String path) throws IOException {
- startTransformation(mediaItem, muxerFactory.create(path, transformation.outputMimeType));
+ startTransformation(mediaItem, muxerFactory.create(path, transformation.containerMimeType));
}
/**
@@ -461,7 +480,7 @@ public final class Transformer {
public void startTransformation(MediaItem mediaItem, ParcelFileDescriptor parcelFileDescriptor)
throws IOException {
startTransformation(
- mediaItem, muxerFactory.create(parcelFileDescriptor, transformation.outputMimeType));
+ mediaItem, muxerFactory.create(parcelFileDescriptor, transformation.containerMimeType));
}
private void startTransformation(MediaItem mediaItem, Muxer muxer) {
@@ -471,7 +490,7 @@ public final class Transformer {
}
MuxerWrapper muxerWrapper =
- new MuxerWrapper(muxer, muxerFactory, transformation.outputMimeType);
+ new MuxerWrapper(muxer, muxerFactory, transformation.containerMimeType);
this.muxerWrapper = muxerWrapper;
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
trackSelector.setParameters(
diff --git a/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerBuilderTest.java b/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerBuilderTest.java
index 7e19f2c250..e27bc2e037 100644
--- a/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerBuilderTest.java
+++ b/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerBuilderTest.java
@@ -30,10 +30,10 @@ import org.junit.runner.RunWith;
public class TransformerBuilderTest {
@Test
- public void setOutputMimeType_unsupportedMimeType_throws() {
+ public void setContainerMimeType_unsupportedMimeType_throws() {
assertThrows(
IllegalStateException.class,
- () -> new Transformer.Builder().setOutputMimeType(MimeTypes.VIDEO_FLV).build());
+ () -> new Transformer.Builder().setContainerMimeType(MimeTypes.VIDEO_FLV).build());
}
@Test