Guig
Guig

Reputation: 10197

ffmpeg - create a video from a sprite

I've an image that represents a short animation as 40 frames in 5 rows 8 columns. How can I use ffmpeg to generate a video from this?

I've read that answer to generate a video from a list of images but I'm unsure about how to tell ffmpeg to read parts of a single image in sequence.

Upvotes: 2

Views: 1120

Answers (2)

Gyan
Gyan

Reputation: 93048

You can use an animated crop to do this. Basic template is,

ffmpeg -loop 1 -i image -vf "crop=iw/8:ih/5:mod(n,8)*iw/8:trunc(n/8)*ih/5" -vframes 40 out.mp4

Basically, the crop extracts out a window of iw/8 x ih/5 each frame and the co-ordinates of the top-left corner of the crop window is animated by the 3rd and 4th arguments, where n is the frame index (starting from 0).

Upvotes: 1

Martin Reiche
Martin Reiche

Reputation: 1672

As far as I no, there is no built in way of doing this using ffmpeg. But I could think of first extracting all the images using two nested for loops and an imagemagick crop and than you can use ffmpeg to generate the video based on the extracted files.

Upvotes: 1

Related Questions