Pad any aspect ratio
Pad any aspect ratio into a larger image by correct pillar or letter boxing (without scaling).
-i input_file \
-filter:v "pad=output_width:output_height:(ow-iw)/2:(oh-ih)/2" \
-c:a copy \
- starts the command
- path, name and extension of the input file
- video padding
- re-encodes using the same audio codec
- path, name and extension of the output file
The video filter is specified by
-filter:v. We advise to avoid the alias
-vfilter and its abbreviation
-vf as well. This resolution independent formula is actually padding any aspect ratio into any larger aspect ratio by pillar or letter boxing, because the video filter uses relative values for input width (iw), input height (ih), output width (ow) and output height (oh). Of course, in this formula the brackets are compulsory. The quotation marks are not mandatory, but we do recommend their usage.
The audio codec is specified by
-codec:audio, which is usually abbreviated as
-c:audio are also possible). We advise to avoid the alias
-acodec. For silent videos you can replace
-c:a copy by
-an; for video with sound you may choose to re-encode with another audio codec which is allowed by the container.