ffmpeg

An ever-growing cheatsheet for ffmpeg. I add things that I think are useful but difficult to unearth or understand.

Contents

  1. Create a stop-motion video based on still images
  2. Add a padded border around a video

Create a stop-motion video based on still images

The below example…

  1. sets a FPS (frames per second) rate of 12
  2. searches the directory for any file beginning with frame-, containing a two digit serial (%02d), and ending in .jpg (e.g. _frame-012.jpg`)
  3. outputs an output.webm file
ffmpeg -r 12 -i frame-%02d.jpg output.webm

Here’s what that looks like:

Source

Add a padded border around a video

The below example sets a new width and height of the desired padding (128) plus the existing width (iw) and existing height (ih). The video is then moved to half that desired padding (64) on the x and y axis so the border is visible. Lastly, the colour is set to a recognised HTML colour name (white).

ffmpeg -i input.webm -filter_complex "[0]pad=w=128+iw:h=128+ih:x=64:y=64:color=white" output.webm

Here’s what that looks like:

And here’s another example for padding the video to fit a 16:9 context:

Source