Create a WEBM from a sequence of images using FFmpeg

Important: read warning before using

please use the controls below to generate the ffmpeg command

Questions? Details for each option listed below.

Operating system:

Optional

About this tool

This tool was created out of the desire to quickly and easily generate WEBM videos from Stable Diffusion image sequences, particularly for the technology board on 4chan.

The form will generate a single-line command for FFmpeg which will run two passes of FFmpeg over your images to create a VP9 video. You should probably use .webm as the file extension but you could also use .mkv, .mp4, .avi, or any container that supports VP9.

I will improve on it when I have time, and may add the ability to target a certain file size. For now, you have to use trial and error with CRF values.

How to use

You need FFmpeg installed on your system.

  1. Set the options you desire.
  2. Copy the code.
  3. Open a command line prompt in the same folder as your images (or in a different directory if you used relative or absolute paths).
  4. Run the command.

Options

Frames per second
How many frames per seccond (fps) you want for the final video.
CRF value
The quality setting for your video. A good default is 31. The number can be anything from 0 to 63. A lower number means better quality and a larger file size. This guide has some good info.
Image filenames suffix
For images generated by the Stable Diffusion Web UI this is everything that comes after the five-digit serial number at the beginning of your images’ file names. Your file names all have to have the same suffix or this will not work. At the very least, you have to input .png or whatever image file format you used.
Output filename
The name of the video file you want to output. This can be a path relative to the directory in which you are working. Do not use double-quotes (").
Operating system
The operating system you're working with. This changes the null output on the first pass to NUL if you’re on Windows or /dev/null if you’re on Linux.
Custom filename pattern (optional)
This overrides anything in the “Image filenames suffix” field and uses exactly what you put in. Read this tutorial to learn more about custom patterns.
Thread queue size (optional)
FFmpeg may give you a warning about thread queue size when encoding your video. Increasing this setting makes the warning go away, but as far as I have found it does not change the end result. I’m not completely sure what it does, but the option is provided anyway. I have had luck setting it to the total number of images I’m encoding. Use at your own risk. Good luck.

Explanation of options/flags in the command line

-r sets the frame rate.

-c:v libvpx-vp9 sets the video codec to VP9.

-b:v 0 sets the video bitrate to “zero” — but what it really does is tell FFmpeg we want to use constant quality encoding.

-crf sets the constant quality factor.

-pix_fmt yuv420p sets the pixel format to that most compatible generally, especially for web browsers.

-g sets the keyframe interval. This is typically set to 10× the frame rate.

-an disables audio.

Warning

This tool comes with no guarantee or warranty whatsoever. Use the same caution you would use when copy-pasting any commands from the internet.

This has not yet been tested on Linux.

References

  1. Official FFmpeg VP9 encoding guide
  2. Using ffmpeg to convert a set of images into a video
  3. ffmpeg showing “Thread message queue blocking” error while encoding (non real time)