Aldo
Aldo

Reputation: 27

Create sliding video from pattern/tile image

Given a 300x300 tile image like this I would like to generate a 1920x1080 video just showing the repeated tile (i.e. tiles are repeated in order to cover all the 1920x1080) but also slowly moving from left to right.

Using ImageMagick I know how to generate a very long image from the tile image, let say a 19200x1080 image:

magick convert -size 19200x1080 tile:tile.jpg long.jpg

But I have no idea on how to use ffmpeg in order to crop a 1920x1080 area from the long image and move the crop area horizontally as time passes.

Any help, also with a completely different approach not based on the long image generated by ImageMagick ?

Upvotes: 0

Views: 797

Answers (2)

GeeMack
GeeMack

Reputation: 5395

This ImageMagick command will create a series of 30 images, 1920x1080, tiled with the 300x300 (or almost any size) input image, and each moving to the left 1/30 the width of the input image more than the last. The output is saved as a GIF, which may then be used as a multi-image input to ffmpeg to make a video.

magick tile.png -duplicate 29 -roll -%[fx:t*w/n]+0 ^
   -set option:distort:viewport 1920x1080 ^
   -virtual-pixel tile -distort srt 0 tiles.gif

The command is in Windows syntax. For *nix change the continued line carets "^" to backslashes "\", or just put it all on one line.

This ffmpeg command reads the image created above, and extends it to about a 10 second loop video.

ffmpeg -stream_loop 9 -r 30 -i tiles.gif tiles.mp4

Adjust the number of duplicates in the ImageMagick command and the input frame rate in ffmpeg for smoothness and speed.

EDITED: To correct number of stream_loops in the ffmpeg command.

Upvotes: 1

fmw42
fmw42

Reputation: 53154

You can do that with my Imagemagick (bash unix) script, overlapcrop. It will do overlap cropping and then make your animation as one output option. See http://www.fmwconcepts.com/imagemagick/overlapcrop/index.php

Input:

enter image description here

# do tiling to a 600x300 larger image as an example:

magick -size 600x300 tile:pattern_blue_and_white.jpg pattern_long.jpg


# do overlap crop and make animation:

overlapcropxx -s 300x300 -o 290x0 -m animation -z 2 -d 30 pattern_long.jpg pattern_animation.gif

Result:

enter image description here

Upvotes: 1

Related Questions