@UnstableApi
public final class TransformerUtil


Utility methods for Transformer.

Summary

Public methods

static ColorInfo
getDecoderOutputColor(
    ColorInfo decoderInputColor,
    boolean isMediaCodecToneMappingRequested
)

Returns the decoder output color taking tone mapping into account.

static int

Returns MediaCodec flags corresponding to C.BufferFlags.

static Pair<StringInteger>
getOutputMimeTypeAndHdrModeAfterFallback(
    @Composition.HdrMode int hdrMode,
    String requestedOutputMimeType,
    @Nullable ColorInfo colorInfo
)

Calculate what the MIME type and HdrMode to use, applying fallback measure if necessary.

static int

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.

static ColorInfo

Adjust for invalid ColorInfo values, by defaulting to SDR_BT709_LIMITED.

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.

static boolean
shouldTranscodeAudio(
    Format inputFormat,
    Composition composition,
    int sequenceIndex,
    TransformationRequest transformationRequest,
    Codec.EncoderFactory encoderFactory,
    MuxerWrapper muxerWrapper
)

Returns whether the audio track should be transcoded.

static boolean
shouldTranscodeVideo(
    Format inputFormat,
    Composition composition,
    int sequenceIndex,
    TransformationRequest transformationRequest,
    Codec.EncoderFactory encoderFactory,
    MuxerWrapper muxerWrapper
)

Returns whether the video track should be transcoded.

Public methods

getDecoderOutputColor

public static ColorInfo getDecoderOutputColor(
    ColorInfo decoderInputColor,
    boolean isMediaCodecToneMappingRequested
)

Returns the decoder output color taking tone mapping into account.

getMediaCodecFlags

public static int getMediaCodecFlags(@C.BufferFlags int flags)

Returns MediaCodec flags corresponding to C.BufferFlags.

getOutputMimeTypeAndHdrModeAfterFallback

public static Pair<StringIntegergetOutputMimeTypeAndHdrModeAfterFallback(
    @Composition.HdrMode int hdrMode,
    String requestedOutputMimeType,
    @Nullable ColorInfo colorInfo
)

Calculate what the MIME type and HdrMode to use, applying fallback measure if necessary.

Parameters
@Composition.HdrMode int hdrMode

The HdrMode.

String requestedOutputMimeType

The desired output MIME type.

@Nullable ColorInfo colorInfo

The ColorInfo.

Returns
Pair<StringInteger>

a Pair of the output MIME type and HdrMode.

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.

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.