Class Presentation.Builder

    • Constructor Detail

      • Builder

        public Builder()
        Creates a builder with default values.
    • Method Detail

      • setResolution

        public Presentation.Builder setResolution​(int height)
        Sets the output resolution using the output height.

        The default value, C.LENGTH_UNSET, corresponds to using the same height as the input. Output width of the displayed frame will scale to preserve the frame's aspect ratio after other transformations.

        For example, a 1920x1440 frame can be scaled to 640x480 by calling setResolution(480).

        Parameters:
        height - The output height of the displayed frame, in pixels.
        Returns:
        This builder.
      • setCrop

        public Presentation.Builder setCrop​(float left,
                                            float right,
                                            float bottom,
                                            float top)
        Crops a smaller (or larger frame), per normalized device coordinates (NDC), where the input frame corresponds to the square ranging from -1 to 1 on the x and y axes.

        left and bottom default to -1, and right and top default to 1, which corresponds to not applying any crop. To crop to a smaller subset of the input frame, use values between -1 and 1. To crop to a larger frame, use values below -1 and above 1.

        Width and height values set may be rescaled by setResolution(int), which is applied after cropping changes.

        Only one of setCrop or setAspectRatio(float, int) can be called for one Presentation.

        Parameters:
        left - The left edge of the output frame, in NDC. Must be less than right.
        right - The right edge of the output frame, in NDC. Must be greater than left.
        bottom - The bottom edge of the output frame, in NDC. Must be less than top.
        top - The top edge of the output frame, in NDC. Must be greater than bottom.
        Returns:
        This builder.
      • setAspectRatio

        public Presentation.Builder setAspectRatio​(float aspectRatio,
                                                   @com.google.android.exoplayer2.transformer.Presentation.Layout int layout)
        Sets the aspect ratio (width/height ratio) for the output frame.

        Resizes a frame's width or height to conform to an aspectRatio, given a Presentation.Layout. aspectRatio defaults to C.LENGTH_UNSET, which corresponds to the same aspect ratio as the input frame. layout defaults to Presentation.LAYOUT_SCALE_TO_FIT

        Width and height values set may be rescaled by setResolution(int), which is applied after aspect ratio changes.

        Only one of setCrop(float, float, float, float) or setAspectRatio can be called for one Presentation.

        Parameters:
        aspectRatio - The aspect ratio (width/height ratio) of the output frame. Must be positive.
        Returns:
        This builder.