Padding video is often needed when the input should be played on a display with different aspect ratio. or just to add extra space for additional content.
For a video padding in FFmpeg, we use a pad filter, which adds a colored padding to the input video frame, which is located to the point[x, y] in the coordination system, where the beginning [0,0] is the top-left corner of the output frame. The size of the output is set by the width and height parameters.
Description of filter parameters
|width, height||width and height of output frame with padding, the value of the width can be derived from the height and vice versa, the default value of both parameters is 0|
|color||RGB color value in hexadecimal form: 0xRRGGBB[@@AA], where AA is decimal value from range (0,1) or any valid color name like black, blue, yellow etc., the default value is black.|
|x,y||coordinates (offset) of the input top-left corner regarding to the top-left corner of the output frame, the default value of both parameters 0|
For example, to create a 30 pixel wide pink frame around an SVGA-sized photo, we can use the command:
ffmpeg -i photo.jpg -vf pad=860:660:30:30:pink pad_photo.jpg