Convert Video into JPEG Sprite

The Angry Saxon picture The Angry Saxon · Mar 30, 2012 · Viewed 9.2k times · Source

I know video can't be turned directly into a motion JPEG but what I'm after is for each frame in a sequence to be taken from the video and turned into a JPEG sprite either horizontal or vertical.

I'll then be using jQuery to animate the jpeg sprite into what looks like a video again.

Answer

Chris O'Sullivan picture Chris O'Sullivan · Apr 29, 2013

You can turn a movie into a stitched together sprite file by doing the following:

1) Use ffmpeg to turn the movie into a bunch of images (this example uses 10 fps)

ffmpeg -i "infile.mp4" -f image2 -vf fps=fps=10 img%03d.jpg

2) Then use imagemagick to stitch them together

files=$(ls img*.jpg | sort -t '-' -n -k 2 | tr '\n' ' ')
convert $files -append output.jpg

BOOM - you've got a sprite sheet.