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
4e3c6c61
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
c45859dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
8 deletions
libraries/common/src/main/java/androidx/media3/common/FrameProcessor.java
libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java
libraries/transformer/src/main/java/androidx/media3/transformer/SamplePipeline.java
libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java
libraries/common/src/main/java/androidx/media3/common/FrameProcessor.java
View file @
4e3c6c61
...
...
@@ -16,6 +16,7 @@
package
androidx
.
media3
.
common
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.opengl.EGLExt
;
import
android.view.Surface
;
import
androidx.annotation.Nullable
;
...
...
@@ -124,6 +125,20 @@ public interface FrameProcessor {
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.
*
* <p>Can be called on any thread.
...
...
libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java
View file @
4e3c6c61
...
...
@@ -21,6 +21,7 @@ import static androidx.media3.common.util.Assertions.checkStateNotNull;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
getLast
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.SurfaceTexture
;
import
android.opengl.EGLContext
;
import
android.opengl.EGLDisplay
;
...
...
@@ -410,6 +411,9 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
}
@Override
public
void
queueInputBitmap
(
Bitmap
inputBitmap
,
long
durationUs
,
int
frameRate
)
{}
@Override
public
Surface
getInputSurface
()
{
return
inputSurface
;
}
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/SamplePipeline.java
View file @
4e3c6c61
...
...
@@ -34,7 +34,7 @@ import androidx.media3.decoder.DecoderInputBuffer;
private
final
long
streamStartPositionUs
;
private
final
MuxerWrapper
muxerWrapper
;
private
final
@C
.
TrackType
int
t
rackType
;
private
final
@C
.
TrackType
int
outputT
rackType
;
private
boolean
muxerWrapperTrackAdded
;
...
...
@@ -42,7 +42,10 @@ import androidx.media3.decoder.DecoderInputBuffer;
Format
firstInputFormat
,
long
streamStartPositionUs
,
MuxerWrapper
muxerWrapper
)
{
this
.
streamStartPositionUs
=
streamStartPositionUs
;
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
)
{
...
...
@@ -113,7 +116,7 @@ import androidx.media3.decoder.DecoderInputBuffer;
}
if
(
isMuxerInputEnded
())
{
muxerWrapper
.
endTrack
(
t
rackType
);
muxerWrapper
.
endTrack
(
outputT
rackType
);
return
false
;
}
...
...
@@ -127,7 +130,7 @@ import androidx.media3.decoder.DecoderInputBuffer;
// buffer from all samples so that they are guaranteed to start from zero in the output file.
try
{
if
(!
muxerWrapper
.
writeSample
(
t
rackType
,
outputT
rackType
,
checkStateNotNull
(
muxerInputBuffer
.
data
),
muxerInputBuffer
.
isKeyFrame
(),
samplePresentationTimeUs
))
{
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/VideoSamplePipeline.java
View file @
4e3c6c61
...
...
@@ -25,6 +25,7 @@ import static androidx.media3.transformer.TransformationRequest.HDR_MODE_TONE_MA
import
static
androidx
.
media3
.
transformer
.
TransformationRequest
.
HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.media.MediaCodec
;
import
android.view.Surface
;
import
androidx.annotation.Nullable
;
...
...
@@ -205,6 +206,11 @@ import org.checkerframework.dataflow.qual.Pure;
}
@Override
public
void
queueInputBitmap
(
Bitmap
inputBitmap
,
long
durationUs
,
int
frameRate
)
{
frameProcessor
.
queueInputBitmap
(
inputBitmap
,
durationUs
,
frameRate
);
}
@Override
public
Surface
getInputSurface
()
{
return
frameProcessor
.
getInputSurface
();
}
...
...
@@ -352,10 +358,15 @@ import org.checkerframework.dataflow.qual.Pure;
this
.
transformationRequest
=
transformationRequest
;
this
.
fallbackListener
=
fallbackListener
;
requestedOutputMimeType
=
transformationRequest
.
videoMimeType
!=
null
?
transformationRequest
.
videoMimeType
:
checkNotNull
(
inputFormat
.
sampleMimeType
);
String
inputSampleMimeType
=
checkNotNull
(
inputFormat
.
sampleMimeType
);
if
(
transformationRequest
.
videoMimeType
!=
null
)
{
requestedOutputMimeType
=
transformationRequest
.
videoMimeType
;
}
else
if
(
MimeTypes
.
isImage
(
inputSampleMimeType
))
{
requestedOutputMimeType
=
MimeTypes
.
VIDEO_H265
;
}
else
{
requestedOutputMimeType
=
inputSampleMimeType
;
}
supportedEncoderNamesForHdrEditing
=
EncoderUtil
.
getSupportedEncoderNamesForHdrEditing
(
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