TransformerUtil
@UnstableApi
public final class TransformerUtil
Utility methods for Transformer.
Summary
Nested types |
|---|
@RequiresApi(value = 35)Utility for setting LogSessionId on MediaFormat (API 35+). |
Public methods |
|
|---|---|
static boolean |
containsSpeedChangingEffects(Returns whether |
static ColorInfo |
getDecoderOutputColor(Returns the decoder output color taking tone mapping into account. |
static @Nullable String |
getImageMimeType(Context context, MediaItem mediaItem)Returns the image MIME type corresponding to a |
static int |
getMediaCodecFlags(@C.BufferFlags int flags)Returns |
static Pair<String, Integer> |
getOutputMimeTypeAndHdrModeAfterFallback(Calculate what the MIME type and |
static int |
@C.TrackTypeReturns the |
static ColorInfo |
getValidColor(@Nullable ColorInfo colorInfo)Adjust for invalid |
static boolean |
Returns whether the provided |
static void |
maybeSetMuxerWrapperAdditionalRotationDegrees(Sets |
static boolean |
shouldTranscodeAudio(Returns whether the audio track should be transcoded. |
static boolean |
shouldTranscodeVideo(Returns whether the video track should be transcoded. |
static boolean |
validateSpeedChangingEffects(Checks whether any speed changing effects at the first position of each pipeline match |
Public methods
containsSpeedChangingEffects
public static boolean containsSpeedChangingEffects(
Effects effects,
boolean ignoreFirstEffect
)
Returns whether Effects contains speed changing effects.
ignoreFirstEffect controls whether TimestampAdjustment and SpeedChangingAudioProcessor are ignored as first elements of the video and audio pipelines, respectively.
getDecoderOutputColor
public static ColorInfo getDecoderOutputColor(
ColorInfo decoderInputColor,
boolean isMediaCodecToneMappingRequested
)
Returns the decoder output color taking tone mapping into account.
getImageMimeType
public static @Nullable String getImageMimeType(Context context, MediaItem mediaItem)
Returns the image MIME type corresponding to a MediaItem.
This method only supports some common image MIME types.
getMediaCodecFlags
public static int getMediaCodecFlags(@C.BufferFlags int flags)
Returns MediaCodec flags corresponding to C.BufferFlags.
getOutputMimeTypeAndHdrModeAfterFallback
public static Pair<String, Integer> getOutputMimeTypeAndHdrModeAfterFallback(
@Composition.HdrMode int hdrMode,
String requestedOutputMimeType,
@Nullable ColorInfo colorInfo
)
Calculate what the MIME type and HdrMode to use, applying fallback measure if necessary.
getProcessedTrackType
@C.TrackType
public static int getProcessedTrackType(@Nullable String mimeType)
Returns the track type constant corresponding to how a specified MIME type should be processed, which may be TRACK_TYPE_UNKNOWN if it could not be determined.
Image MIME types are processed as TRACK_TYPE_VIDEO.
See getTrackType for more details.
getValidColor
public static ColorInfo getValidColor(@Nullable ColorInfo colorInfo)
Adjust for invalid ColorInfo values, by defaulting to SDR_BT709_LIMITED.
isImage
public static boolean isImage(Context context, MediaItem mediaItem)
Returns whether the provided MediaItem corresponds to an image.
maybeSetMuxerWrapperAdditionalRotationDegrees
public static void maybeSetMuxerWrapperAdditionalRotationDegrees(
MuxerWrapper muxerWrapper,
ImmutableList<Effect> videoEffects,
Format inputFormat
)
Sets the additionalRotationDegrees on the given MuxerWrapper if the given videoEffects only contains a mix of regular rotations and no-ops. A regular rotation is a rotation divisible by 90 degrees.
shouldTranscodeAudio
public static boolean shouldTranscodeAudio(
Format inputFormat,
Composition composition,
int sequenceIndex,
TransformationRequest transformationRequest,
Codec.EncoderFactory encoderFactory,
MuxerWrapper muxerWrapper
)
Returns whether the audio track should be transcoded.
shouldTranscodeVideo
public static boolean shouldTranscodeVideo(
Format inputFormat,
Composition composition,
int sequenceIndex,
TransformationRequest transformationRequest,
Codec.EncoderFactory encoderFactory,
MuxerWrapper muxerWrapper
)
Returns whether the video track should be transcoded.
validateSpeedChangingEffects
public static boolean validateSpeedChangingEffects(
Effects effects,
SpeedProvider speedProvider
)
Checks whether any speed changing effects at the first position of each pipeline match
speedProvider.
The method verifies that any TimestampAdjustment or SpeedChangingAudioProcessor instance set as the first effect of its pipeline has a SpeedProvider equal to speedProvider.
If no speed changing effects are present, this method returns true.