Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
executable file 33 lines (23 sloc) 638 Bytes
#!/usr/bin/env bash
# ffframes: Extract the frames from a video.
# Use the `FRAMERATE` variable to control the framerate; by default `-vsync 0` will be used.
set -eo pipefail
FRAMERATE=""
function help {
echo "Usage: ffframes <input> <output-dir>"
exit
}
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
[[ $# -eq 2 && -f $1 && ! -e $2 ]] || help
installed ffmpeg || { >&2 echo "Missing ffmpeg."; exit 1; }
mkdir -p "${2}"
if [[ -z "${FRAMERATE}" ]]; then
flags="-vsync 0"
else
flags="-vf fps=${FRAMERATE}"
fi
ffmpeg -i "${1}" ${flags} "${2}/frame-%05d.png"