Skip to content

Instantly share code, notes, and snippets.

@johnnoel
Created October 15, 2022 20:33
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 johnnoel/72dc758a4eb1984533b240863b930403 to your computer and use it in GitHub Desktop.
Save johnnoel/72dc758a4eb1984533b240863b930403 to your computer and use it in GitHub Desktop.
Video file screenshot script
# single video file
./screenshotter.sh video.mp4 250
# directory of files
find . -type f -maxdepth 1 -printf '"%f"\n' -exec screenshots.sh {} 250 \;
!/bin/bash
duration=$(ffprobe -v quiet -print_format json -show_format -show_streams "$1" | jq -r .format.duration)
fps=$(echo "scale=5; $duration / $2" | bc)
filename=$(basename "$1")
#filename="${filenameonly%.*}"
#echo $1 $duration $fps $filename
mkdir -p "screenshots/$filename"
ffmpeg -v quiet -stats -i "$1" -vf fps=1/$fps "screenshots/$filename/%06d.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment