Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4a0ea37a
authored
Nov 19, 2021
by
kimvde
Committed by
tonihei
Nov 19, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Transformer: deprecate setOutputMimeType
PiperOrigin-RevId: 411010270
parent
674d70e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
76 deletions
docs/transforming-media.md
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java
docs/transforming-media.md
View file @
4a0ea37a
...
@@ -6,7 +6,6 @@ The [Transformer API][] can be used to convert media streams. It takes an input
...
@@ -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:
...
@@ -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.
...
@@ -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 =
...
@@ -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.
...
@@ -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.
...
@@ -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
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java
View file @
4a0ea37a
...
@@ -250,17 +250,8 @@ public final class TranscodingTransformer {
...
@@ -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
)
{
...
@@ -269,23 +260,6 @@ public final class TranscodingTransformer {
...
@@ -269,23 +260,6 @@ public final class TranscodingTransformer {
}
}
/**
/**
* 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 {
...
@@ -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 {
...
@@ -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
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
View file @
4a0ea37a
...
@@ -208,17 +208,8 @@ public final class Transformer {
...
@@ -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
)
{
...
@@ -227,23 +218,6 @@ public final class Transformer {
...
@@ -227,23 +218,6 @@ public final class Transformer {
}
}
/**
/**
* 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.
*
*
* <p>This is equivalent to {@link Transformer#setListener(Listener)}.
* <p>This is equivalent to {@link Transformer#setListener(Listener)}.
...
@@ -433,9 +407,9 @@ public final class Transformer {
...
@@ -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 {
...
@@ -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
...
...
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java
View file @
4a0ea37a
...
@@ -30,10 +30,10 @@ import org.junit.runner.RunWith;
...
@@ -30,10 +30,10 @@ import org.junit.runner.RunWith;
public
class
TransformerBuilderTest
{
public
class
TransformerBuilderTest
{
@Test
@Test
public
void
set
Container
MimeType_unsupportedMimeType_throws
()
{
public
void
set
Output
MimeType_unsupportedMimeType_throws
()
{
assertThrows
(
assertThrows
(
IllegalStateException
.
class
,
IllegalStateException
.
class
,
()
->
new
Transformer
.
Builder
().
set
Container
MimeType
(
MimeTypes
.
VIDEO_FLV
).
build
());
()
->
new
Transformer
.
Builder
().
set
Output
MimeType
(
MimeTypes
.
VIDEO_FLV
).
build
());
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment