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
c32794f0
authored
Feb 03, 2023
by
tofunmi
Committed by
microkatz
Feb 08, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Update sample pipelines and frame processors to handle image input.
PiperOrigin-RevId: 506965394
parent
7684949f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
8 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java
library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SamplePipeline.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java
library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java
View file @
c32794f0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
util
;
package
com
.
google
.
android
.
exoplayer2
.
util
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.opengl.EGLExt
;
import
android.opengl.EGLExt
;
import
android.view.Surface
;
import
android.view.Surface
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
...
@@ -123,6 +124,20 @@ public interface FrameProcessor {
...
@@ -123,6 +124,20 @@ public interface FrameProcessor {
long
DROP_OUTPUT_FRAME
=
-
2
;
long
DROP_OUTPUT_FRAME
=
-
2
;
/**
/**
* Provides an input {@link Bitmap} to the {@link FrameProcessor}.
*
* <p>Can be called on any thread.
*
* @param inputBitmap The {@link Bitmap} queued to the {@link FrameProcessor}.
* @param durationUs The duration for which to display the {@code inputBitmap}, in microseconds.
* @param frameRate The frame rate at which to display the {@code inputBitmap}, in frames per
* second.
*/
// TODO(b/262693274): Remove duration & frameRate parameters when EditedMediaItem can be signalled
// down to the processors.
void
queueInputBitmap
(
Bitmap
inputBitmap
,
long
durationUs
,
int
frameRate
);
/**
* Returns the input {@link Surface}, where {@link FrameProcessor} consumes input frames from.
* Returns the input {@link Surface}, where {@link FrameProcessor} consumes input frames from.
*
*
* <p>Can be called on any thread.
* <p>Can be called on any thread.
...
...
library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java
View file @
c32794f0
...
@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
...
@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
getLast
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
getLast
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.SurfaceTexture
;
import
android.graphics.SurfaceTexture
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
import
android.opengl.EGLDisplay
;
...
@@ -408,6 +409,9 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
...
@@ -408,6 +409,9 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
}
}
@Override
@Override
public
void
queueInputBitmap
(
Bitmap
inputBitmap
,
long
durationUs
,
int
frameRate
)
{}
@Override
public
Surface
getInputSurface
()
{
public
Surface
getInputSurface
()
{
return
inputSurface
;
return
inputSurface
;
}
}
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SamplePipeline.java
View file @
c32794f0
...
@@ -34,7 +34,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
...
@@ -34,7 +34,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
private
final
long
streamStartPositionUs
;
private
final
long
streamStartPositionUs
;
private
final
MuxerWrapper
muxerWrapper
;
private
final
MuxerWrapper
muxerWrapper
;
private
final
@C
.
TrackType
int
t
rackType
;
private
final
@C
.
TrackType
int
outputT
rackType
;
private
boolean
muxerWrapperTrackAdded
;
private
boolean
muxerWrapperTrackAdded
;
...
@@ -42,7 +42,10 @@ import com.google.android.exoplayer2.video.ColorInfo;
...
@@ -42,7 +42,10 @@ import com.google.android.exoplayer2.video.ColorInfo;
Format
firstInputFormat
,
long
streamStartPositionUs
,
MuxerWrapper
muxerWrapper
)
{
Format
firstInputFormat
,
long
streamStartPositionUs
,
MuxerWrapper
muxerWrapper
)
{
this
.
streamStartPositionUs
=
streamStartPositionUs
;
this
.
streamStartPositionUs
=
streamStartPositionUs
;
this
.
muxerWrapper
=
muxerWrapper
;
this
.
muxerWrapper
=
muxerWrapper
;
trackType
=
MimeTypes
.
getTrackType
(
firstInputFormat
.
sampleMimeType
);
outputTrackType
=
MimeTypes
.
isImage
(
firstInputFormat
.
sampleMimeType
)
?
C
.
TRACK_TYPE_VIDEO
:
MimeTypes
.
getTrackType
(
firstInputFormat
.
sampleMimeType
);
}
}
protected
static
TransformationException
createNoSupportedMimeTypeException
(
Format
format
)
{
protected
static
TransformationException
createNoSupportedMimeTypeException
(
Format
format
)
{
...
@@ -113,7 +116,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
...
@@ -113,7 +116,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
}
}
if
(
isMuxerInputEnded
())
{
if
(
isMuxerInputEnded
())
{
muxerWrapper
.
endTrack
(
t
rackType
);
muxerWrapper
.
endTrack
(
outputT
rackType
);
return
false
;
return
false
;
}
}
...
@@ -127,7 +130,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
...
@@ -127,7 +130,7 @@ import com.google.android.exoplayer2.video.ColorInfo;
// buffer from all samples so that they are guaranteed to start from zero in the output file.
// buffer from all samples so that they are guaranteed to start from zero in the output file.
try
{
try
{
if
(!
muxerWrapper
.
writeSample
(
if
(!
muxerWrapper
.
writeSample
(
t
rackType
,
outputT
rackType
,
checkStateNotNull
(
muxerInputBuffer
.
data
),
checkStateNotNull
(
muxerInputBuffer
.
data
),
muxerInputBuffer
.
isKeyFrame
(),
muxerInputBuffer
.
isKeyFrame
(),
samplePresentationTimeUs
))
{
samplePresentationTimeUs
))
{
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java
View file @
c32794f0
...
@@ -25,6 +25,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkState;
...
@@ -25,6 +25,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkState;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Util
.
SDK_INT
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Util
.
SDK_INT
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec
;
import
android.view.Surface
;
import
android.view.Surface
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
...
@@ -205,6 +206,11 @@ import org.checkerframework.dataflow.qual.Pure;
...
@@ -205,6 +206,11 @@ import org.checkerframework.dataflow.qual.Pure;
}
}
@Override
@Override
public
void
queueInputBitmap
(
Bitmap
inputBitmap
,
long
durationUs
,
int
frameRate
)
{
frameProcessor
.
queueInputBitmap
(
inputBitmap
,
durationUs
,
frameRate
);
}
@Override
public
Surface
getInputSurface
()
{
public
Surface
getInputSurface
()
{
return
frameProcessor
.
getInputSurface
();
return
frameProcessor
.
getInputSurface
();
}
}
...
@@ -352,10 +358,15 @@ import org.checkerframework.dataflow.qual.Pure;
...
@@ -352,10 +358,15 @@ import org.checkerframework.dataflow.qual.Pure;
this
.
transformationRequest
=
transformationRequest
;
this
.
transformationRequest
=
transformationRequest
;
this
.
fallbackListener
=
fallbackListener
;
this
.
fallbackListener
=
fallbackListener
;
requestedOutputMimeType
=
String
inputSampleMimeType
=
checkNotNull
(
inputFormat
.
sampleMimeType
);
transformationRequest
.
videoMimeType
!=
null
?
transformationRequest
.
videoMimeType
if
(
transformationRequest
.
videoMimeType
!=
null
)
{
:
checkNotNull
(
inputFormat
.
sampleMimeType
);
requestedOutputMimeType
=
transformationRequest
.
videoMimeType
;
}
else
if
(
MimeTypes
.
isImage
(
inputSampleMimeType
))
{
requestedOutputMimeType
=
MimeTypes
.
VIDEO_H265
;
}
else
{
requestedOutputMimeType
=
inputSampleMimeType
;
}
supportedEncoderNamesForHdrEditing
=
supportedEncoderNamesForHdrEditing
=
EncoderUtil
.
getSupportedEncoderNamesForHdrEditing
(
EncoderUtil
.
getSupportedEncoderNamesForHdrEditing
(
requestedOutputMimeType
,
inputFormat
.
colorInfo
);
requestedOutputMimeType
,
inputFormat
.
colorInfo
);
...
...
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