Skip to content

Instantly share code, notes, and snippets.

@luruke
Created March 3, 2014 13:58
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 luruke/927b818debc41228ca89 to your computer and use it in GitHub Desktop.
Save luruke/927b818debc41228ca89 to your computer and use it in GitHub Desktop.
Generate Frames from videos using ffmpeg
#!/bin/bash
for i in videos/webm/*.webm; do
if [ -e "$i" ]; then
file=`basename "$i" .webm`
if ! [[ "$file" =~ ^interview ]] ; then
mkdir -p "img/sprites/$file"
total_frames=`ffmpeg -i $i -vcodec copy -acodec copy -f null dev/null 2>&1 | grep 'frame=' | cut -f 3 -d ' '`
numframes=10
rate=`echo "scale=0; $total_frames/$numframes" | bc`
ffmpeg -i $i -f image2 -vf "select='not(mod(n,$rate))'" -vframes $numframes -vsync vfr -y "img/sprites/$file/frame-%d.jpeg"
ffmpeg -i $i -f image2 -vf "select='not(mod(n,$rate))'" -vframes 1 -vsync vfr -vf "smartblur=lr=5" -y "img/sprites/$file/blur-frame-%d.jpeg"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment