Skip to content

Instantly share code, notes, and snippets.

@drillbits
Created February 15, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drillbits/4ba4c12c791114422e14142eea05479c to your computer and use it in GitHub Desktop.
Save drillbits/4ba4c12c791114422e14142eea05479c to your computer and use it in GitHub Desktop.
Convert video to images per N frame
#!/bin/bash
if [ $# -lt 1 ]; then
echo "${0} requires more than 1 arguments"
echo "${0} input [output] [framestep]"
exit 1
fi
INPUT=${1}
OUTPUT=${2:-img%03d.jpg}
FRAMESTEP=${3:-1}
mkdir -p "${OUTPUT%/*}"
CMD="ffmpeg -i ${INPUT} -an -vsync 0 -vf framestep=${FRAMESTEP} ${OUTPUT}"
# echo ${CMD}
echo -n "convert ${INPUT} to ${OUTPUT} every ${FRAMESTEP}-th frame [Y/n] "
read YN
case ${YN} in
"" | "Y" | "y" | "yes" | "Yes" | "YES") ${CMD};;
*) echo "noop";;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment