diff --git a/docs/transforming-media.md b/docs/transforming-media.md index 4d180260dd..ec75d6070f 100644 --- a/docs/transforming-media.md +++ b/docs/transforming-media.md @@ -6,7 +6,6 @@ The [Transformer API][] can be used to convert media streams. It takes an input media stream, applies changes to it as configured by the app, and produces the corresponding output file. The available transformations are: -* Transmuxing between container formats. * Track removal. * Flattening of slow motion videos or, in other words, their conversion into normal videos that retain the desired slow motion effects, but can be played @@ -16,7 +15,7 @@ corresponding output file. The available transformations are: ## Starting a transformation ## -To transform media, you need add the following dependency to your app’s +To transform media, you need to add the following dependency to your app’s `build.gradle` file: ~~~ @@ -28,8 +27,7 @@ where `2.X.X` is your preferred ExoPlayer version. You can then start a transformation by building a `Transformer` instance and calling `startTransformation` on it. The code sample below starts a -transformation that removes the audio track from the input and sets the output -container format to WebM: +transformation that removes the audio track from the input: ~~~ // Configure and create a Transformer instance. @@ -37,7 +35,6 @@ Transformer transformer = new Transformer.Builder() .setContext(context) .setRemoveAudio(true) - .setContainerMimeType(MimeTypes.VIDEO_WEBM) .setListener(transformerListener) .build(); // Start the transformation. @@ -52,7 +49,9 @@ builder. a `ParcelFileDescriptor` indicating where the output should be written. The input can be a progressive or an adaptive stream, but the output is always a progressive stream. For adaptive inputs, the highest resolution tracks are -always selected for the transformation. +always selected for the transformation. The input can be of any container format +supported by ExoPlayer (see the [Supported formats page][] for details), but the +output is always an MP4 file. Multiple transformations can be executed sequentially with the same `Transformer` instance, but concurrent transformations with the same instance @@ -137,4 +136,5 @@ flattened version of the video instead of the original one. Currently, Samsung's slow motion format is the only one supported. [Transformer API]: {{ site.exo_sdk }}/transformer/Transformer.html +[Supported formats page]: {{ site.baseurl }}/supported-formats.html diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java index 887b9f8598..ccff860f1d 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java @@ -250,17 +250,8 @@ public final class TranscodingTransformer { } /** - * Sets the MIME type of the output. The default value is {@link MimeTypes#VIDEO_MP4}. Supported - * values are: - * - * - * - * @param outputMimeType The MIME type of the container. - * @return This builder. - * @deprecated Use {@link #setContainerMimeType} instead. + * @deprecated This feature will be removed in a following release and the MIME type of the + * output will always be MP4. */ @Deprecated public Builder setOutputMimeType(String outputMimeType) { @@ -268,23 +259,6 @@ public final class TranscodingTransformer { return this; } - /** - * Sets the MIME type of the output container. The default value is {@link MimeTypes#VIDEO_MP4}. - * Supported values are: - * - * - * - * @param containerMimeType The MIME type of the container. - * @return This builder. - */ - public Builder setContainerMimeType(String containerMimeType) { - this.containerMimeType = containerMimeType; - return this; - } - /** * Sets the video MIME type of the output. The default value is to use the same MIME type as the * input. Supported values are: @@ -545,9 +519,9 @@ public final class TranscodingTransformer { * *

Concurrent transformations on the same TranscodingTransformer object are not allowed. * - *

The output can contain at most one video track and one audio track. Other track types are - * ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and - * audio streams are selected. + *

The output is an MP4 file. It can contain at most one video track and one audio track. Other + * track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest + * bitrate video and audio streams are selected. * * @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the * {@link Muxer} and on the output container format. For the {@link FrameworkMuxer}, they are @@ -570,9 +544,9 @@ public final class TranscodingTransformer { * *

Concurrent transformations on the same TranscodingTransformer object are not allowed. * - *

The output can contain at most one video track and one audio track. Other track types are - * ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and - * audio streams are selected. + *

The output is an MP4 file. It can contain at most one video track and one audio track. Other + * track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest + * bitrate video and audio streams are selected. * * @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the * {@link Muxer} and on the output container format. For the {@link FrameworkMuxer}, they are diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java index 0d43c67c3b..356772a9ed 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java @@ -208,17 +208,8 @@ public final class Transformer { } /** - * Sets the MIME type of the output. The default value is {@link MimeTypes#VIDEO_MP4}. Supported - * values are: - * - *

- * - * @param outputMimeType The MIME type of the container. - * @return This builder. - * @deprecated Use {@link #setContainerMimeType} instead. + * @deprecated This feature will be removed in a following release and the MIME type of the + * output will always be MP4. */ @Deprecated public Builder setOutputMimeType(String outputMimeType) { @@ -226,23 +217,6 @@ public final class Transformer { return this; } - /** - * Sets the MIME type of the output container. The default value is {@link MimeTypes#VIDEO_MP4}. - * Supported values are: - * - * - * - * @param containerMimeType The MIME type of the output. - * @return This builder. - */ - public Builder setContainerMimeType(String containerMimeType) { - this.containerMimeType = containerMimeType; - return this; - } - /** * Sets the {@link Transformer.Listener} to listen to the transformation events. * @@ -433,9 +407,9 @@ public final class Transformer { * *

Concurrent transformations on the same Transformer object are not allowed. * - *

The output can contain at most one video track and one audio track. Other track types are - * ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and - * audio streams are selected. + *

The output is an MP4 file. It can contain at most one video track and one audio track. Other + * track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest + * bitrate video and audio streams are selected. * * @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the * {@link Muxer} and on the output container format. For the {@link FrameworkMuxer}, they are @@ -458,9 +432,9 @@ public final class Transformer { * *

Concurrent transformations on the same Transformer object are not allowed. * - *

The output can contain at most one video track and one audio track. Other track types are - * ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and - * audio streams are selected. + *

The output is an MP4 file. It can contain at most one video track and one audio track. Other + * track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest + * bitrate video and audio streams are selected. * * @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the * {@link Muxer} and on the output container format. For the {@link FrameworkMuxer}, they are diff --git a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java index 73454b27ae..8cfba3156d 100644 --- a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java +++ b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java @@ -30,10 +30,10 @@ import org.junit.runner.RunWith; public class TransformerBuilderTest { @Test - public void setContainerMimeType_unsupportedMimeType_throws() { + public void setOutputMimeType_unsupportedMimeType_throws() { assertThrows( IllegalStateException.class, - () -> new Transformer.Builder().setContainerMimeType(MimeTypes.VIDEO_FLV).build()); + () -> new Transformer.Builder().setOutputMimeType(MimeTypes.VIDEO_FLV).build()); } @Test