overlay


Overlay one video on top of another.

It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.

It accepts the following parameters:

A description of the accepted options follows.

'x'
'y'

Set the expression for the x and y coordinates of the overlaid video on the main video. Default value is "0" for both expressions. In case the expression is invalid, it is set to a huge value (meaning that the overlay will not be displayed within the output visible area).

'eof_action'

See .

'eval'

Set when the expressions for 'x', and 'y' are evaluated.

It accepts the following values:

'init'

only evaluate expressions once during the filter initialization or when a command is processed

'frame'

evaluate expressions for each incoming frame

Default value is 'frame'.

'shortest'

See .

'format'

Set the format for the output video.

It accepts the following values:

'yuv420'

force YUV420 output

'yuv422'

force YUV422 output

'yuv444'

force YUV444 output

'rgb'

force packed RGB output

'gbrp'

force planar RGB output

'auto'

automatically pick format

Default value is 'yuv420'.

'repeatlast'

See .

'alpha'

Set format of alpha of the overlaid video, it can be straight or premultiplied. Default is straight.

The 'x', and 'y' expressions can contain the following parameters.

'main_w, W'
'main_h, H'

The main input width and height.

'overlay_w, w'
'overlay_h, h'

The overlay input width and height.

'x'
'y'

The computed values for x and y. They are evaluated for each new frame.

'hsub'
'vsub'

horizontal and vertical chroma subsample values of the output format. For example for the pixel format "yuv422p" hsub is 2 and vsub is 1.

'n'

the number of input frame, starting from 0

'pos'

the position in the file of the input frame, NAN if unknown

't'

The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.

This filter also supports the options.

Note that the n, pos, t variables are available only when evaluation is done per frame, and will evaluate to NAN when 'eval' is set to 'init'.

Be aware that frames are taken from each input video in timestamp order, hence, if their initial timestamps differ, it is a good idea to pass the two inputs through a setpts=PTS-STARTPTS filter to have them begin in the same zero timestamp, as the example for the movie filter does.

You can chain together more overlays but you should test the efficiency of such approach.

This filter supports the following commands:

'x'
'y'

Modify the x and y of the overlay input. The command accepts the same syntax of the corresponding option.

If the specified expression is not valid, it is kept at its current value.