mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
media stream, applies changes to it as configured by the app, and produces the
|
||||||
corresponding output file. The available transformations are:
|
corresponding output file. The available transformations are:
|
||||||
|
|
||||||
* Transmuxing between container formats.
|
|
||||||
* Track removal.
|
* Track removal.
|
||||||
* Flattening of slow motion videos or, in other words, their conversion into
|
* 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
|
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 ##
|
## 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:
|
`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
|
You can then start a transformation by building a `Transformer` instance and
|
||||||
calling `startTransformation` on it. The code sample below starts a
|
calling `startTransformation` on it. The code sample below starts a
|
||||||
transformation that removes the audio track from the input and sets the output
|
transformation that removes the audio track from the input:
|
||||||
container format to WebM:
|
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
// Configure and create a Transformer instance.
|
// Configure and create a Transformer instance.
|
||||||
|
|
@ -37,7 +35,6 @@ Transformer transformer =
|
||||||
new Transformer.Builder()
|
new Transformer.Builder()
|
||||||
.setContext(context)
|
.setContext(context)
|
||||||
.setRemoveAudio(true)
|
.setRemoveAudio(true)
|
||||||
.setContainerMimeType(MimeTypes.VIDEO_WEBM)
|
|
||||||
.setListener(transformerListener)
|
.setListener(transformerListener)
|
||||||
.build();
|
.build();
|
||||||
// Start the transformation.
|
// Start the transformation.
|
||||||
|
|
@ -52,7 +49,9 @@ builder.
|
||||||
a `ParcelFileDescriptor` indicating where the output should be written. The
|
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
|
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
|
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
|
Multiple transformations can be executed sequentially with the same
|
||||||
`Transformer` instance, but concurrent transformations with the same instance
|
`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.
|
Currently, Samsung's slow motion format is the only one supported.
|
||||||
|
|
||||||
[Transformer API]: {{ site.exo_sdk }}/transformer/Transformer.html
|
[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
|
* @deprecated This feature will be removed in a following release and the MIME type of the
|
||||||
* values are:
|
* output will always be MP4.
|
||||||
*
|
|
||||||
* <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
|
@Deprecated
|
||||||
public Builder setOutputMimeType(String outputMimeType) {
|
public Builder setOutputMimeType(String outputMimeType) {
|
||||||
|
|
@ -268,23 +259,6 @@ public final class TranscodingTransformer {
|
||||||
return this;
|
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
|
* Sets the video MIME type of the output. The default value is to use the same MIME type as the
|
||||||
* input. Supported values are:
|
* input. Supported values are:
|
||||||
|
|
@ -545,9 +519,9 @@ public final class TranscodingTransformer {
|
||||||
*
|
*
|
||||||
* <p>Concurrent transformations on the same TranscodingTransformer object are not allowed.
|
* <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
|
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||||
* ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and
|
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||||
* audio streams are selected.
|
* bitrate video and audio streams are selected.
|
||||||
*
|
*
|
||||||
* @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the
|
* @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
|
* {@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>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
|
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||||
* ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and
|
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||||
* audio streams are selected.
|
* bitrate video and audio streams are selected.
|
||||||
*
|
*
|
||||||
* @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the
|
* @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
|
* {@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
|
* @deprecated This feature will be removed in a following release and the MIME type of the
|
||||||
* values are:
|
* output will always be MP4.
|
||||||
*
|
|
||||||
* <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
|
@Deprecated
|
||||||
public Builder setOutputMimeType(String outputMimeType) {
|
public Builder setOutputMimeType(String outputMimeType) {
|
||||||
|
|
@ -226,23 +217,6 @@ public final class Transformer {
|
||||||
return this;
|
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.
|
* 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>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
|
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||||
* ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and
|
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||||
* audio streams are selected.
|
* bitrate video and audio streams are selected.
|
||||||
*
|
*
|
||||||
* @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the
|
* @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
|
* {@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>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
|
* <p>The output is an MP4 file. It can contain at most one video track and one audio track. Other
|
||||||
* ignored. For adaptive bitrate {@link MediaSource media sources}, the highest bitrate video and
|
* track types are ignored. For adaptive bitrate {@link MediaSource media sources}, the highest
|
||||||
* audio streams are selected.
|
* bitrate video and audio streams are selected.
|
||||||
*
|
*
|
||||||
* @param mediaItem The {@link MediaItem} to transform. The supported sample formats depend on the
|
* @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
|
* {@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 {
|
public class TransformerBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setContainerMimeType_unsupportedMimeType_throws() {
|
public void setOutputMimeType_unsupportedMimeType_throws() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalStateException.class,
|
IllegalStateException.class,
|
||||||
() -> new Transformer.Builder().setContainerMimeType(MimeTypes.VIDEO_FLV).build());
|
() -> new Transformer.Builder().setOutputMimeType(MimeTypes.VIDEO_FLV).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue