This makes pleasing, moving backgrounds "images", with bright and friendly colors, and a "fuzzy milkglass" pixel distortion overlay.
I already did something similar in 2019, in Python: https://github.com/BenWiederhake/noisycols#noisycols
My motivation this time was:
- Do it in Rust, because … get better at Rust.
- Create a video, because … pretty moving colors!
This eats up incredible amounts of computational power, so this must be multi-threaded in Rust.
- Tweak constants in
src/main.rs
- Generate images with
cargo run --release
- Compile the image sequence into a sharable video with:
ffmpeg -stream_loop 2 -y -f image2 -framerate 10 -i build/image_1234567890_frame%05d.png -vcodec libx264 -crf 22 -profile:v baseline -vf format=yuv420p -movflags +faststart /tmp/video.mp4
The cargo step can be sped up even further by writing:
[build]
rustflags = ["-C", "target-cpu=native"]
into .cargo/config.toml
The reason for the long ffmpeg incantation is:
-stream_loop 2
: Not all video players support seamless looping, and this is a stop-gap measure to make it seamless at least half of the time.-framerate
can of course be increased arbitrarily, but if you want a smoother (and not just faster) experience, then you'll also need to increase the constantNUM_FRAMES
insrc/main.rs
.1234567890
has to be replaced by the actual timestamp used duringcargo run
.libx264
,baseline
,yuv240p
,faststart
, and.mp4
are necessary in order to support in-client video playback in Telegram, which is where I share these videos with friends.crf 22
means quite good quality. Note that due to the nature of the video, the blobs move but the milkglass distortion does not move. This is probably an unexpected video signal that should be destroyed by compression, although in my experience it is actually handled quite well.
The result could look like this:
Video of pleasing, colorful blobs
Feel free to tweak the constants and experiment yourself! In the directory making-of/
I put some (ugly) results that I got while choosing the right parameters.
Nothing, actually. I'm happy and "done" with this project.
Feel free to dive in! Open an issue or submit PRs.