Sunday, October 03, 2010

PNG to PNG Sequences

When I'm putting videos together, one thing I often find handy is being able to turn a single PNG image into a PNG sequence. That means I can import the resulting sequence straight into Avidemux or VirtualDub and to add filters to it.

#!/bin/bash
#
# Convert png file into a png sequence for video use

for i in {1..150}; do
    j=$(printf "%04d" $i)
    cp "input.png" "pngs"$j".png"
done

The Bash script above does that - it takes a file called input.png, and creates copies of it to make a PNG sequence of 150 frames numbered from png0001.png to png0150.png.

No comments: