2021-05-08 16:53:26 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
#####################################################
|
|
|
|
#
|
|
|
|
# This script will export your video to frames and
|
|
|
|
# use the application "primitive" to reproduce the
|
|
|
|
# image with polygonal primitive shapes. Then the
|
|
|
|
# converted frames are p
|
|
|
|
#
|
|
|
|
# The modes available for the -m argument are:
|
|
|
|
# 0=combo
|
|
|
|
# 1=triangle
|
|
|
|
# 2=rect
|
|
|
|
# 3=ellipse
|
|
|
|
# 4=circle
|
|
|
|
# 5=rotatedrect
|
|
|
|
# 6=beziers
|
|
|
|
# 7=rotatedellipse
|
|
|
|
# 8=polygon
|
|
|
|
#
|
|
|
|
# primitive repo : https://github.com/fogleman/primitive
|
|
|
|
#
|
|
|
|
# Usage: bash ffmpeg/frames/primitive.sh <input video> <output video>
|
|
|
|
#
|
|
|
|
#####################################################
|
|
|
|
|
|
|
|
INPUT="${1}"
|
|
|
|
OUTPUT="${2}"
|
|
|
|
|
|
|
|
MODE=1
|
|
|
|
NUMBER=100
|
|
|
|
|
|
|
|
# Check if output file extension is .mov
|
|
|
|
if [[ "${OUTPUT}" != *".mov" ]]; then
|
|
|
|
echo "Please use an .mov extension on your output file argument"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p frames
|
|
|
|
|
|
|
|
ffmpeg -i "${INPUT}" frames/frame-%06d.png
|
|
|
|
|
|
|
|
FRAMES=frames/*.png
|
|
|
|
|
|
|
|
for frame in ${FRAMES}; do
|
|
|
|
echo "Processing $frame with primitive..."
|
|
|
|
# Run the "primitive" application on every frame
|
2021-05-09 13:11:40 +00:00
|
|
|
primitive -i "${frame}" -o "${frame}" -n ${NUMBER} -m ${MODE}
|
2021-05-08 16:53:26 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
ffmpeg -f image2 -i frames/frame-%06d.png -c:v prores_ks -profile:v 3 "${OUTPUT}"
|
|
|
|
|
|
|
|
rm -rf frames
|