#!/bin/bash -e

#####################################################
#
# This script splits a video into an image sequence
# and then stitches the image sequence back into a
# ProRes video.
#
# Usage: bash ffmpeg/frames/basic.sh <input video> <output video>
#
#####################################################

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

# 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

sleep 20

ffmpeg -f image2 -i frames/frame-%06d.png -c:v prores_ks -profile:v 3 "${OUTPUT}"

rm -rf frames