The new version of the library came about because I was playing around with rendering animated previews of patterns from the information inside the pattern files. The preview images stored in the pattern files are limited to 100 pixels and 150 frames, but (thanks to some hints from @wizard) I was able to work out a way to read the live previews of the LEDs from a real live Pixelblaze using @zranger1’s pixelblaze-client
library, arrange them in space according to the pixelmap, and render them as 1D/2D/3D animations. Here’s what “Cube Fire 2D/3D” looks like on a variety of different layouts:
I asked @zranger1 if I could make a few changes to his library to make the preview capture easier, he graciously said yes, and from there it just snowballed. I got the animations I wanted, but then I thought…why stop there? As many of you will appreciate, once you start tinkering it’s hard to stop.
Here are a few examples of what you can do with the new library:
RECORDVIDEO
Think of it as a VCR for Pixelblaze patterns. When run, it will begin capturing whatever is on the LEDs into a 2D buffer. When you’ve recorded enough, press [Ctrl]-[C] and it will begin rendering the captured frames into an animated PNG suitable for inserting into forum posts. If you want an MP4 instead, convert the PNG afterwards with ffmpeg -i {filename}.png {filename}.mp4
.
Syntax
The syntax is:
usage: recordVideo.py [-h] [--ipAddress IPADDRESS] [--fileName FILENAME]
options:
-h, --help show this help message and exit
--ipAddress IPADDRESS The IP address of the Pixelblaze to record
--fileName FILENAME The filename for the recording to be created
~*~
And what good is a VCR without something to play on it? I remembered @zranger1’s E.131 proxy and realized that the same technique could be used to serve any kind of content to a Pixelblaze. There’s a new example program in the pixelblaze-client
library that will play animated GIFs and PNGs onto a nearby Pixelblaze:
=> played to a 32x32 matrix =>
…but what I really want, what I really really want is video. Fortunately, Python is the duck tape of the internet; with only a few changes to the example program we can use OpenCV to read videos frame-by-frame and send them to a Pixelblaze.
PLAYVIDEO
If OpenCV can read it, you can play it on your Pixelblaze. It has a ways to go before it will replace your home theater setup, but nevertheless it’s amazing what these little things can do!
Syntax
The syntax is:
usage: playVideo [-h] --ipAddress IPADDRESS --fileName FILENAME
options:
-h, --help show this help message and exit
--ipAddress IPADDRESS The IP address of the Pixelblaze
--fileName FILENAME The video file to be sent to the Pixelblaze, or 'webcam' to use the webcam
~*~
So turn your speakers up, find a comfy chair, and prepare to be amazed by the wonders of moving pictures, as played through a Pixelblaze:
Installation
The pixelblaze-client
library is a prerequisite, naturally. If you don’t have it, pip install pixelblaze-client
.
The source code is here:
recordVideo.py (8.1 KB) and playVideo.py (5.7 KB)
And if you chmod +x
the Python files, you’ll be able to execute them directly from the command line without having to specify python
in front.