user1710344
user1710344

Reputation: 111

Tile a set of images and pan/scroll across them using ffmpeg

I have a set of very large images that I would like to tile horizontally and pan across using ffmpeg.

The images are relatively large and can be created using magick using:

magick convert -compress lzw -size 90000x800 xc:"rgb(160,160,255)" test001.tif
... and so on

The command I've gotten closest with is the following:

ffmpeg -loop 1 -i test%03d.tif -vf "tile=4x1,scroll=horizontal=0.05,crop=800:600:0:0,format=yuv420p" -t 10 output.mp4

The issues with the above command:

Any pointers for how scroll/pan across multiple input images would be greatly appreciated!

Upvotes: 0

Views: 1189

Answers (1)

kesh
kesh

Reputation: 5473

Start with 90000x800 images (hundreds of them), use input framerate of 1 fps (for the ease of presentation), let M = 90000

step 1: tile=2x1:overlap=1 appends the next image to the previous: [Img1|Img2],[Img2|Img3], [Img3|Img4]...

step 2: fps=N increases the frame rate to N fps by repeating each tiled frame N times

step 3: crop=w=1280:h=800:x=mod(n,N)*M/N:y=0 positions the current video frame on the image then crops out the rest. On frame n=N, the next pair of images will be set so it resets the frame position to 0.

ffmpeg -r 1 -i test%03d.tif \ 
  -vf 'tile=2x1:overlap=1, \
       fps=N, \
       crop=w=1280:h=800:x=mod(n,N)*M/N:y=0' \
  -pix_fmt yuv420p output.mp4

Pick your number for N and substitute the symbols with actual numbers, and you should be ready to roll (I hope...)

But now, how do you pick N? It'll depends on your input frame rate (which is preliminary set to 1), your desired output frame rate, and the image transition time...

Say you want each image to stay on screen for 2 seconds and the output frame rate to be 30 fps, then each image should appear on 2*30=60 frames. So, set N = 60 and the input frame rate 30/60 = 0.5.

I have not tested the command, so give it a try and I'd be happy to troubleshoot if not working. Also, I'm curious if it's reasonably fast.

===============================

Update: requested to change input to 800x800 images instead of 90000x800.

Change tile and crop as follows:

ffmpeg -r 1 -i test%03d.tif \ 
  -vf 'tile=3x1:overlap=2, \
       fps=N, \
       crop=w=1280:h=800:x=mod(n,N)*800/N:y=0' \
  -pix_fmt yuv420p output.mp4

Also N needs to be readjusted by Nnew = 800/90000 * N or thereabouts.

Upvotes: 1

Related Questions