animation/stipple.sh

58 lines
1.3 KiB
Bash

#!/bin/bash
INPUT=`realpath "${1}"`
OUTPUT=`realpath "${2}"`
WIDTH=404
HEIGHT=374
DOTSIZE=4
MAXGENERATIONS=25
MAXPARTICLES=500
MINDOTSIZE=0.8
LINE=0.8
FILL=true
MODE="stipple"
IMAGES=""
#files in dir
for png in "${INPUT}/"*.png ; do
filename=`basename "${png}"`
name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
tmp=`mktemp`.png
bash white.sh "${png}" "${tmp}"
cd ~/src/stipple_gen/
if [ "${IMAGES}" == "" ]; then
part=`echo "${name}" | awk -F'_0' '{print $1}'`
IMAGES="${OUTPUT}/${part}_%06d_rendered.png"
VIDEO="${OUTPUT}/${part}.mov"
fi
bash stipple_gen.sh \
--inputImage "${tmp}" \
--outputImage "${OUTPUT}/${name}_rendered.png" \
--outputSVG "${OUTPUT}/${name}.svg" \
--canvasWidth $WIDTH \
--canvasHeight $HEIGHT \
--dotSizeFactor $DOTSIZE \
--windowWidth $WIDTH \
--windowHeight $HEIGHT \
--maxGenerations $MAXGENERATIONS \
--minDotSize $MINDOTSIZE \
--line $LINE \
--fill $FILL \
--maxParticles $MAXPARTICLES \
--mode $MODE
rm "${tmp}"
cd ~/src/animation/
if [ "${MODE}" != "tsp" ]; then
opt=`mktemp`.svg
svgsort "${OUTPUT}/${name}.svg" "${opt}"
mv "${opt}" "${OUTPUT}/${name}.svg"
fi
done
ffmpeg -r 12 -f image2 -i "${IMAGES}" \
-c:v prores_ks -profile:v 3 \
"${VIDEO}"