Skip to content

Text Generator

Register name used to load filter: txtgen
This is a JavaScript filter. It is not checked during graph resolution and needs explicit loading.
Author: GPAC Team

This filter generates text streams based on the provided src file. By default, the filter uses a lorem ipsum text file
The type parameter sets the text generation mode. If set to 'txt', the filter will generate text based on the source file
If set to 'utc', the filter will generate text based on the current UTC time. If set to 'ntp', the filter will generate text based on the current NTP time
When the unit is set to 'w', the filter will generate text based on words. When set to 'l', the filter will generate text based on lines
The fdur parameter sets the frame duration of the text stream. Total duration of the text stream is set by the dur parameter. If set to 0/0, the text stream will be infinite
The rollup parameter enables roll-up mode up to the specified number of lines. In roll-up mode, the filter will accumulate text until the specified number of lines is reached.
When the number of lines is reached, the filter will remove the first line and continue accumulating text
You would use rollup in combination with unit set to 'l' to create a roll-up subtitle effect. Or set unit to 'w' to create a roll-up text effect.
The lmax parameter sets the maximum number of characters in a line. If the line in the source file is longer than this, the excess text will be wrapped. 0 means no limit
When rt is set to true, the filter will generate text in real-time. If set to false, the filter will generate text as fast as possible

Options

src (str, default: /usr/share/gpac/scripts/jsf/txtgen/lipsum.txt): source of text. If not set, the filter will use lorem ipsum text

type (enum, default: txt): type of text to generate

  • txt: plain text (uses src option)
  • utc: UTC time
  • ntp: NTP time

unit (enum, default: l): minimum unit of text from the source

  • w: word
  • l: line

fdur (frac, default: 1/1): duration of each frame

lmax (uint, default: 32): maximum number of characters in a line. If the line in the source file is longer than this, the excess text will be wrapped. 0 means no limit

dur (frac, default: 0/0): duration of the text stream

rollup (uint, default: 0): enable roll-up mode up to the specified number of lines

lock (bool, default: false): lock timing to text generation

rt (bool, default: true): real-time mode

Was this page helpful?