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
26a73605
authored
Sep 28, 2022
by
samrobinson
Committed by
Marc Baechinger
Oct 20, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Demo: Split video Effect generation out of createTransformer.
PiperOrigin-RevId: 477524540
parent
05ce639e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
29 deletions
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
26a73605
...
@@ -272,11 +272,38 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -272,11 +272,38 @@ public final class TransformerActivity extends AppCompatActivity {
.
setEnableFallback
(
bundle
.
getBoolean
(
ConfigurationActivity
.
ENABLE_FALLBACK
))
.
setEnableFallback
(
bundle
.
getBoolean
(
ConfigurationActivity
.
ENABLE_FALLBACK
))
.
build
());
.
build
());
ImmutableList
.
Builder
<
Effect
>
effects
=
new
ImmutableList
.
Builder
<>();
transformerBuilder
.
setVideoEffects
(
createVideoEffectsListFromBundle
(
bundle
));
if
(
bundle
.
getBoolean
(
ConfigurationActivity
.
ENABLE_DEBUG_PREVIEW
))
{
transformerBuilder
.
setDebugViewProvider
(
new
DemoDebugViewProvider
());
}
}
return
transformerBuilder
.
addListener
(
new
Transformer
.
Listener
()
{
@Override
public
void
onTransformationCompleted
(
MediaItem
mediaItem
,
TransformationResult
transformationResult
)
{
TransformerActivity
.
this
.
onTransformationCompleted
(
filePath
);
}
@Override
public
void
onTransformationError
(
MediaItem
mediaItem
,
TransformationException
exception
)
{
TransformerActivity
.
this
.
onTransformationError
(
exception
);
}
})
.
build
();
}
private
ImmutableList
<
Effect
>
createVideoEffectsListFromBundle
(
Bundle
bundle
)
{
@Nullable
@Nullable
boolean
[]
selectedEffects
=
boolean
[]
selectedEffects
=
bundle
.
getBooleanArray
(
ConfigurationActivity
.
DEMO_EFFECTS_SELECTIONS
);
bundle
.
getBooleanArray
(
ConfigurationActivity
.
DEMO_EFFECTS_SELECTIONS
);
if
(
selectedEffects
!=
null
)
{
if
(
selectedEffects
==
null
)
{
return
ImmutableList
.
of
();
}
ImmutableList
.
Builder
<
Effect
>
effects
=
new
ImmutableList
.
Builder
<>();
if
(
selectedEffects
[
0
])
{
if
(
selectedEffects
[
0
])
{
effects
.
add
(
MatrixTransformationFactory
.
createDizzyCropEffect
());
effects
.
add
(
MatrixTransformationFactory
.
createDizzyCropEffect
());
}
}
...
@@ -328,8 +355,8 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -328,8 +355,8 @@ public final class TransformerActivity extends AppCompatActivity {
// uses a linear RGB color space internally. Meaning this is only for demonstration
// uses a linear RGB color space internally. Meaning this is only for demonstration
// purposes and it does not display a correct sepia frame.
// purposes and it does not display a correct sepia frame.
float
[]
sepiaMatrix
=
{
float
[]
sepiaMatrix
=
{
0.393f
,
0.349f
,
0.272f
,
0
,
0.769f
,
0.686f
,
0.534f
,
0
,
0.189f
,
0.168f
,
0.131f
,
0
,
0
,
0.393f
,
0.349f
,
0.272f
,
0
,
0.769f
,
0.686f
,
0.534f
,
0
,
0.189f
,
0.168f
,
0.131f
,
0
,
0
,
0
,
0
,
0
,
1
0
,
1
};
};
effects
.
add
((
RgbMatrix
)
(
presentationTimeUs
,
useHdr
)
->
sepiaMatrix
);
effects
.
add
((
RgbMatrix
)
(
presentationTimeUs
,
useHdr
)
->
sepiaMatrix
);
break
;
break
;
...
@@ -366,8 +393,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -366,8 +393,7 @@ public final class TransformerActivity extends AppCompatActivity {
effects
.
add
(
effects
.
add
(
new
HslAdjustment
.
Builder
()
new
HslAdjustment
.
Builder
()
.
adjustHue
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_HUE
))
.
adjustHue
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_HUE
))
.
adjustSaturation
(
.
adjustSaturation
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_SATURATION
))
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_SATURATION
))
.
adjustLightness
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_LIGHTNESS
))
.
adjustLightness
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_LIGHTNESS
))
.
build
());
.
build
());
}
}
...
@@ -398,29 +424,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -398,29 +424,7 @@ public final class TransformerActivity extends AppCompatActivity {
if
(
selectedEffects
[
10
])
{
if
(
selectedEffects
[
10
])
{
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
}
}
transformerBuilder
.
setVideoEffects
(
effects
.
build
());
return
effects
.
build
();
}
if
(
bundle
.
getBoolean
(
ConfigurationActivity
.
ENABLE_DEBUG_PREVIEW
))
{
transformerBuilder
.
setDebugViewProvider
(
new
DemoDebugViewProvider
());
}
}
return
transformerBuilder
.
addListener
(
new
Transformer
.
Listener
()
{
@Override
public
void
onTransformationCompleted
(
MediaItem
mediaItem
,
TransformationResult
transformationResult
)
{
TransformerActivity
.
this
.
onTransformationCompleted
(
filePath
);
}
@Override
public
void
onTransformationError
(
MediaItem
mediaItem
,
TransformationException
exception
)
{
TransformerActivity
.
this
.
onTransformationError
(
exception
);
}
})
.
build
();
}
}
@RequiresNonNull
({
@RequiresNonNull
({
...
...
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