Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Video into JPEG Sprite

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.

like image 784
The Angry Saxon Avatar asked Mar 29 '12 22:03

The Angry Saxon


Video Answer


2 Answers

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.

like image 198
Chris O'Sullivan Avatar answered Sep 17 '22 00:09

Chris O'Sullivan


You can use ffmpeg to extract frames into images. The following command pulls a single frame five seconds in:

ffmpeg -i "infile.mp4" -r 1 -ss 00:00:05 -t 00:00:01 -vframes 1 -f image2 -y "image.jpg"

like image 41
knabar Avatar answered Sep 19 '22 00:09

knabar