#!/bin/bash

INPUT="${1}"
STYLE="${2}"
OUTPUT="${3}"

mkdir -p frames
mkdir -p neural-frames

ffmpeg -i "${INPUT}" frames/frame-%06d.png

FRAMES=frames/*.png

for frame in ${FRAMES}; do
	echo "Running style transfer $frame -> neural-$frame ..."
	bash python/style_transfer.sh "${frame}" "${STYLE}" "neural-${frame}"
done

ffmpeg -i neural-frames/frame-%06d.png -r 24 -c:v libx264 -crf 12 -an "${OUTPUT}"

# cleanup frames directories when done
rm -rf frames
#rm -rf neural-frames