Class DrawtextFilter

  • All Implemented Interfaces:
    VideoFilter

    public class DrawtextFilter
    extends Filter
    Add text to a video. An implementation of the drawtext filter from the FFMPEG Documentation.

    https://write.corbpie.com/how-to-do-a-text-watermark-in-ffmpeg/ -vf "drawtext=text='a watermark':x=10:y=H-th-10:fontfile=/pathto/font.ttf:fontsize=10:fontcolor=white:shadowcolor=black:shadowx=2:shadowy=2"

    • Constructor Detail

      • DrawtextFilter

        public DrawtextFilter​(java.lang.String text,
                              java.lang.String posX,
                              java.lang.String posY)
        Parameters:
        text - The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is mandatory if no file is specified with the parameter textfile.
        posX - X Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
        posY - Y Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
      • DrawtextFilter

        public DrawtextFilter​(java.lang.String text,
                              java.lang.String posX,
                              java.lang.String posY,
                              java.lang.String fontName,
                              java.lang.Double fontSize,
                              Color fontColor)
                       throws java.lang.IllegalArgumentException
        Parameters:
        text - The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is mandatory if no file is specified with the parameter textfile.
        posX - X Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
        posY - Y Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
        fontName - The font family to be used for drawing text. By default Sans.
        fontSize - The font size to be used for drawing text. The default value of fontsize is 16.
        fontColor - The color to be used for drawing fonts. The default value of fontcolor is "black".
        Throws:
        java.lang.IllegalArgumentException
      • DrawtextFilter

        public DrawtextFilter​(java.lang.String text,
                              java.lang.String posX,
                              java.lang.String posY,
                              java.io.File fontFile,
                              java.lang.Double fontSize,
                              Color fontColor)
                       throws java.lang.IllegalArgumentException
        Parameters:
        text - The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is mandatory if no file is specified with the parameter textfile.
        posX - X Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
        posY - Y Position of watermark text. The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
        fontFile - The font file to be used for drawing text. The path must be included. This parameter is mandatory if the fontconfig support is disabled.
        fontSize - The font size to be used for drawing text. The default value of fontsize is 16.
        fontColor - The color to be used for drawing fonts. The default value of fontcolor is "black".
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • setShadow

        public DrawtextFilter setShadow​(Color shadowColor,
                                        java.lang.Integer shadowX,
                                        java.lang.Integer shadowY)
        Parameters:
        shadowColor - Color of shadow
        shadowX - X Position of shadow, relative to text
        shadowY - Y Position of shadow, relative to text
        Returns:
        this instance
      • setBox

        public DrawtextFilter setBox​(java.lang.Integer borderWidth,
                                     Color color)
        Used to draw a box around text using the background color.
        Parameters:
        borderWidth - Set the width of the border to be drawn around the box using boxcolor. The default value of boxborderw is 0.
        color - The color to be used for drawing box around text. The default value of boxcolor is "white".
        Returns:
        this instance.
      • setBorder

        public DrawtextFilter setBorder​(java.lang.Integer borderWidth,
                                        Color color)
        Parameters:
        borderWidth - Set the width of the border to be drawn around the text using bordercolor. The default value of borderw is 0.
        color - Set the color to be used for drawing border around text. The default value of bordercolor is "black".
        Returns:
        this instance
      • setLineSpacing

        public DrawtextFilter setLineSpacing​(java.lang.Integer lineSpacing)
        Parameters:
        lineSpacing - Set the line spacing in pixels of the border to be drawn around the box using box. The default value of line_spacing is 0.
        Returns:
        this instance