2021-08-10 22:07:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-09-16 14:42:59 +00:00
|
|
|
###########################
|
|
|
|
#
|
|
|
|
# Export a video to an image sequence at a
|
|
|
|
# particular framerate.
|
|
|
|
#
|
|
|
|
###########################
|
|
|
|
|
2022-10-26 00:07:58 +00:00
|
|
|
MULTIPLE=3
|
2021-11-27 03:01:07 +00:00
|
|
|
FPS=24
|
|
|
|
RATE=`echo "scale=0;${FPS}/${MULTIPLE}" | bc`
|
|
|
|
TIMESTR=""
|
2021-09-09 00:53:32 +00:00
|
|
|
|
2021-08-10 22:07:38 +00:00
|
|
|
INPUT="${1}"
|
|
|
|
OUTPUT="${2}"
|
2021-09-09 00:53:32 +00:00
|
|
|
INVERT="${3}"
|
2021-11-27 03:01:07 +00:00
|
|
|
START_FRAME=${4}
|
|
|
|
END_FRAME=${5}
|
2021-08-10 22:07:38 +00:00
|
|
|
|
2023-01-02 17:21:40 +00:00
|
|
|
WIDTH=323 #80
|
|
|
|
HEIGHT=242 #60
|
2021-08-10 22:07:38 +00:00
|
|
|
|
2021-11-27 03:01:07 +00:00
|
|
|
if [[ "${INVERT}" != "" ]] && [[ "${INVERT}" == "negative" ]]; then
|
2021-09-10 04:36:46 +00:00
|
|
|
INVERT="negate,"
|
2021-11-27 03:01:07 +00:00
|
|
|
else
|
|
|
|
INVERT=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${START_FRAME}" != "" ]]; then
|
|
|
|
START=`echo "scale=6;${START_FRAME}/${FPS}" | bc`
|
|
|
|
TIMESTR="${TIMESTR} -ss ${START}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${END_FRAME}" != "" ]]; then
|
|
|
|
TIME=`echo "scale=6;(${END_FRAME}-${START_FRAME})/${FPS}" | bc`
|
|
|
|
TIMESTR="${TIMESTR} -t ${TIME}"
|
2021-09-09 00:53:32 +00:00
|
|
|
fi
|
|
|
|
|
2021-08-10 22:07:38 +00:00
|
|
|
mkdir -p "${OUTPUT}"
|
|
|
|
|
2021-12-08 22:27:00 +00:00
|
|
|
ffmpeg -y -re -r ${FPS} -i "${INPUT}" \
|
2021-11-27 03:01:07 +00:00
|
|
|
${TIMESTR} \
|
2021-08-10 22:07:38 +00:00
|
|
|
-f image2 \
|
2021-09-09 00:53:32 +00:00
|
|
|
-r ${RATE} \
|
2021-09-10 04:36:46 +00:00
|
|
|
-vf ${INVERT}crop=in_h/3*4:in_h,scale=$WIDTH:$HEIGHT,setsar=1:1 \
|
2021-11-27 03:01:07 +00:00
|
|
|
-q:v 1 -qmin 1 -qmax 1 \
|
2021-08-10 22:07:38 +00:00
|
|
|
"${OUTPUT}/image_%06d.png"
|