How to pad a video with ffmpeg to e.g. have even dimensions

Mon Jun 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Made a small screencast and unfortunately it had odd dimensions, which worked fine in the webm format it was produced, but could not be converted to e.g. mp4 or mov with the default settings of ffmpeg.

I don't want to resize it, can a black border just be added to even it out? Yes. The trick turned out to be to specify a bigger size for the output video with "pad". Let's say the video is orginally 593x575, and then just quick and dirty make the output 600x600:

ffmpeg -i odd.webm -vf "pad=width=600:height=600:x=0:y=0:color=black" even.mp4

And then you specify with x and y where the video should be placed within that padding. Simplest is to just put it in the upper right corner, with x=0:y=0.

Source: https://stackoverflow.com/questions/48485799/ffmpeg-extend-not-resize-video-size-by-adding-box-or-border