#!/bin/bash

source ./fonctions.sh

if [ 0 == $# ] ; then
	arg="8"
else
	arg="$@"
fi

echo ARG $arg
set -e

SRCDIR="capture"

for foo in $arg
do

	make rafaleur adhoc
	sleep 1

	DSTDIR=$(printf "p8/%03d" $foo)
	if [ ! -d $DSTDIR ] ; then
	   echo MAKE DIR $DSTDIR
	   mkdir  $DSTDIR
	fi
	# 
	./adhoc capture/00666.fimg /dev/shm/T$foo.tga $foo
	convert /dev/shm/T$foo.tga Photos/fusion-$foo.jpg
	rm -f /dev/shm/T$foo.tga
	#
	rm -f $DSTDIR/*.tga
	time nice ./rafaleur $foo
	sleep 1
	nice -15 ./encode.sh $DSTDIR Films/fusion-$foo.mp4
	sleep 1
	echo
done

