2

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.

Guig
  • 9,891
  • 7
  • 64
  • 126

2 Answers2

1

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.

Martin Reiche
  • 1,642
  • 1
  • 16
  • 27
  • 1
    One could use the Imagemagick tiled crop function to crop the image into 40 tile images by specifying the tile width and height, then pipe the resulting images to ffmpeg. See https://imagemagick.org/Usage/crop/#crop_tile. `convert image.suffix -crop WxH +repage TIFF:- | ffmpeg ... `. This assumes that ffmpeg accepts TIFF files as input and that you know the arguments you want to use for ffmpeg. – fmw42 Sep 26 '18 at 22:39
1

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

Gyan
  • 85,394
  • 9
  • 169
  • 201