Convert PNG frames to WebM video
How to convert a sequence of PNG images to a VP8 WebM video. This is handy for converting a rendered animation from, for example, Blender to WebM.
To summarize the process: first we need to convert the PNG frames to a YUV4MPEG file, then vpxenc can encode that to a webm file.
On Ubuntu Linux
1. Install the mjpegtools package - this gives you the png2yuv command. (MJPEG Tools project)
2. Install the vpx-tools package - this gives you the vpxenc command. (Note: vpxenc is part of the official VP8 SDK.)
3. Use png2yuv to convert the frames to a YUV4MPEG file (aka Y4M, I420 or IYUV). For example:
png2yuv -I p -f 24 -b 1 -n 1440 -j big_buck_bunny_%05d.png > my.yuv
Let's break that down:
-I p Non-interlaced.
-f 24 24 frames per second.
-b 1 Start with image number 1.
-n 1440 The number of images to process.
-j big_buck_bunny_%05d.png The file name pattern. %05d is the expanded to 00001, 00002, ..., 01440. %03d would expand to 001, 002, etc.
> my.yuv Send output to a file instead of dumping it to your console screen.
4. Encode the YUV file with with vpxenc. For example:
vpxenc --good --cpu-used=0 --auto-alt-ref=1 --lag-in-frames=16 --end-usage=vbr --passes=2 --threads=2 --target-bitrate=3000 -o my.webm my.yuv
This will output a file my.webm. Perhaps the most important option above is --target-bitrate. This is your primary control for the file size (lower bitrate, smaller file). For details on the other encoding options please refer to the VP8 Encoder Parameter Guidelines.
Windows
Use the same commands as for Linux (above). The only difference should be where you get the tools:
The MJPEG Tools project provides binaries for Windows (get the one with mingw-bin in it's name).
vpxenc.exe can be found in bin/Win32 of the pre-built Visual Studio zip on the webm downloads page. (eg vpx-vp8-debug-src-x86-win32mt-vs9-v1.1.0.zip)
Happy encoding!