24 October, 2013

Create Counting Video


On a couple of occasions, I've had the need to create a source video for video processing and testing video processing commands.  A common need is to create a counting video by generating a series of frames and stitching them together at a pre-defined frame rate.

Below is a mechanism for doing so;


$ cat createVideo 
#!/bin/bash

ws=/var/tmp/cache
rm -rf $ws
mkdir -p $ws

for i in `seq 300`; do
  N=$(printf %03d $i)
  convert -size 640x480 -background white -fill black -pointsize 120 -gravity center label:$i $ws/frame-$N.jpg
done

ffmpeg -y -r 2/1 -i $ws/frame-%03d.jpg -r 30/1 $ws/video.avi
mplayer $ws/video.avi


Cheers.

No comments: