#!/usr/bin/env bash

if [ $# -eq 0 ]; then
  echo "Usage: $0 path/to/envitopnm"
  exit 1
fi

for i in `ls *-t0000-c*.img`
do
  $1 --image=$i --autoscale=true | pnmtopng > $i.png
done

rm -f video.mp4
ffmpeg -framerate 15 -i demo-t0000-c%04d.img.png -s:v 320x200 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p video.mp4

rm demo-t0000-c*.img.png
