Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg - create a video from a sprite

Tags:

ffmpeg

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.

like image 760
Guig Avatar asked Oct 24 '25 20:10

Guig


2 Answers

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).

like image 92
Gyan Avatar answered Oct 28 '25 01:10

Gyan


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.

like image 45
Martin Reiche Avatar answered Oct 28 '25 02:10

Martin Reiche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!