Add paddings

Add paddings with the color "violet" to the input video. The output video size is 640x480, and the top-left corner of the input video is placed at column 0, row 40

pad=640:480:0:40:violet

The example above is equivalent to the following command:

pad=width=640:height=480:x=0:y=40:color=violet

Pad the input to get an output with dimensions increased by 3/2, and put the input video at the center of the padded area:

pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"

Pad the input to get a squared output with size equal to the maximum value between the input width and height, and put the input video at the center of the padded area:

pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"

Pad the input to get a final w/h ratio of 16:9:

pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"

In case of anamorphic video, in order to set the output display aspect correctly, it is necessary to use sar in the expression, according to the relation:

(ih * X / ih) * sar = output_dar
X = output_dar / sar

Thus the previous example needs to be modified to:

pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"

Double the output size and put the input video in the bottom-right corner of the output padded area:

pad="2*iw:2*ih:ow-iw:oh-ih"