Text expansion
If 'expansion' is set to strftime
, the filter recognizes strftime() sequences in the provided text and expands them accordingly. Check the documentation of strftime(). This feature is deprecated.
If 'expansion' is set to none
, the text is printed verbatim.
If 'expansion' is set to normal
(which is the default), the following expansion mechanism is used.
The backslash character '\', followed by any character, always expands to the second character.
Sequences of the form %{...}
are expanded. The text between the braces is a function name, possibly followed by arguments separated by ':'. If the arguments contain special characters or delimiters (':' or '}'), they should be escaped.
Note that they probably must also be escaped as the value for the 'text' option in the filter argument string and as the filter argument in the filtergraph description, and possibly also for the shell, that makes up to four levels of escaping; using a text file avoids these problems.
The following functions are available:
expr, e
-
The expression evaluation result.
It must take one argument specifying the expression to be evaluated, which accepts the same constants and functions as the x and y values. Note that not all constants should be used, for example the text size is not known when evaluating the expression, so the constants text_w and text_h will have an undefined value.
expr_int_format, eif
-
Evaluate the expression's value and output as formatted integer.
The first argument is the expression to be evaluated, just as for the expr function. The second argument specifies the output format. Allowed values are 'x', 'X', 'd' and 'u'. They are treated exactly as in the
printf
function. The third parameter is optional and sets the number of positions taken by the output. It can be used to add padding with zeros from the left. gmtime
-
The time at which the filter is running, expressed in UTC. It can accept an argument: a strftime() format string.
localtime
-
The time at which the filter is running, expressed in the local time zone. It can accept an argument: a strftime() format string.
metadata
-
Frame metadata. Takes one or two arguments.
The first argument is mandatory and specifies the metadata key.
The second argument is optional and specifies a default value, used when the metadata key is not found or empty.
n, frame_num
-
The frame number, starting from 0.
pict_type
-
A 1 character description of the current picture type.
pts
-
The timestamp of the current frame. It can take up to three arguments.
The first argument is the format of the timestamp; it defaults to
flt
for seconds as a decimal number with microsecond accuracy;hms
stands for a formatted [-]HH:MM:SS.mmm timestamp with millisecond accuracy.gmtime
stands for the timestamp of the frame formatted as UTC time;localtime
stands for the timestamp of the frame formatted as local time zone time.The second argument is an offset added to the timestamp.
If the format is set to
hms
, a third argument24HH
may be supplied to present the hour part of the formatted timestamp in 24h format (00-23).If the format is set to
localtime
orgmtime
, a third argument may be supplied: a strftime() format string. By default, YYYY-MM-DD HH:MM:SS format will be used.