Skip to content

Instantly share code, notes, and snippets.

@WSAyan
Created May 27, 2020 04:22
Show Gist options
  • Save WSAyan/d54760ded3c4cc9bf6f4676a586dabb2 to your computer and use it in GitHub Desktop.
Save WSAyan/d54760ded3c4cc9bf6f4676a586dabb2 to your computer and use it in GitHub Desktop.
extracts images from all video files in a directory using ffmpeg
# extract images from video file
# sh extract-img.sh -e [extension] -fr [frame rate]
_ext=""
_fr=1
while getopts ":e:o:f:n:" opt; do
case $opt in
e)
_ext="$OPTARG"
;;
f)
_fr="$OPTARG"
;;
\?)
echo "ERROR: Invalid option: -$OPTARG" >&2
exit
;;
esac
done
i=0
for file in *.$_ext; do
ffmpeg -i $file -r $_fr output_"$i"_%04d.jpeg
i=$((i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment