Subtitle: How a simple greedy algorithm and some FFmpeg magic can turn a folder of chaotic images into a seamless, dreamy infinite loop.
Have you ever taken a video file, exploded it into individual frames, shuffled them, and then tried to put it back together without looking at the filenames?
It sounds like a puzzle for a supercomputer. But it turns out, you can do it on a laptop with a few lines of Python and a philosophy I call Heuristic Engineering.
I’m excited to release SlideShowLoop, a new open-source tool that organizes chaotic collections of images into coherent, seamless video loops.
The Problem: Entropy
If you have a folder of 500 images, they usually have no relationship to each other. If you play them as a slideshow, it’s a strobe light of random information.
I wanted a way to find the "River of Time" flowing through that folder. I wanted to sort them not by date or name, but by visual flow.
The Solution: The "Good Enough" Sort
The script ignores metadata entirely. It creates a chain of images based purely on raw pixel similarity.
If we wanted to do this "perfectly" (finding the absolute optimal path through the images), we’d be solving the Traveling Salesman Problem. That’s NP-Hard. It would take the lifetime of the universe to solve for a large dataset.
Instead, SlideShowLoop embraces imperfection:
Aggressive Downscaling: It crushes your 4K images into tiny 64x64 grayscale squares. This acts as a blur filter, ignoring grain and focusing on composition and light.
Greedy Algorithms: It uses a "Nearest Neighbor" approach. It grabs a frame, looks for the best match available right now, and moves on.
The "1000" Threshold: It uses a lazy optimization. If it finds a frame that is "close enough" (a Mean Squared Error < 1000), it stops searching and takes it.
It always picks the image with the most difference to start the sequence, which makes the algorithm deterministic for the same data set.
It doesn’t look for the perfect cut. It looks for the next cut. And because it mimics how our eyes perceive motion, the result feels surprisingly natural.
The Result: Liquid Time
Once the Python script sorts the chaos, it hands the list off to FFmpeg.
Using a specific set of flags (specifically the minterpolate filter), we force the computer to hallucinate motion between the frames. Because the images are sorted by similarity, the optical flow vectors are short and smooth.
The result is a "dreamy," morphing video.
Static photos of a landscape seem to pan and rotate.
A person in a red shirt might liquid-morph into a red car.
Disjointed moments become a continuous stream of consciousness.
It creates a "latent space" walk aesthetic—similar to generative AI video—but achieved entirely through pixel algebra and standard codecs.
Efficiency
The hidden bonus of this approach? Compression.
Video codecs (like H.264) hate chaos. A random slideshow results in a massive file size because every frame is different. But by sorting the images by similarity, we artificially create "temporal redundancy." The encoder sees that Frame B is almost identical to Frame A, and compresses it aggressively.
We are getting high-definition motion for a file size only twice as large as the static slideshow video is.
Try it out
The code is open source and available now. All you need is Python and FFmpeg.
Check out the Repo here: https://github.com/BuckRogers1965/Slide-Show-Loop
Dump a folder of images in, run the script, and watch the computer dream.
No comments:
Post a Comment