mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Transformer: deprecate setOutputMimeType
PiperOrigin-RevId: 411010270
This commit is contained in:
parent
674d70e8f3
commit
4a0ea37aae
4 changed files with 24 additions and 76 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link MimeTypes#VIDEO_MP4}
|
||||
* <li>{@link MimeTypes#VIDEO_WEBM} from API level 21
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link MimeTypes#VIDEO_MP4}
|
||||
* <li>{@link MimeTypes#VIDEO_WEBM} from API level 21
|
||||
* </ul>
|
||||
*
|
||||
* @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 {
|
|||
*
|
||||
* <p>Concurrent transformations on the same TranscodingTransformer object are not allowed.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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 {
|
|||
*
|
||||
* <p>Concurrent transformations on the same TranscodingTransformer object are not allowed.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link MimeTypes#VIDEO_MP4}
|
||||
* <li>{@link MimeTypes#VIDEO_WEBM} from API level 21
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link MimeTypes#VIDEO_MP4}
|
||||
* <li>{@link MimeTypes#VIDEO_WEBM} from API level 21
|
||||
* </ul>
|
||||
*
|
||||
* @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 {
|
|||
*
|
||||
* <p>Concurrent transformations on the same Transformer object are not allowed.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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 {
|
|||
*
|
||||
* <p>Concurrent transformations on the same Transformer object are not allowed.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue