# Pixelblaze-client Python Library Release: Updated and Upgraded!

**URL:** <https://forum.electromage.com/t/pixelblaze-client-python-library-release-updated-and-upgraded/2566>\
**Category:** Patterns and Code\
**Created:** [October 13, 2022, 5:17pm UTC](https://forum.electromage.com/t/pixelblaze-client-python-library-release-updated-and-upgraded/2566 "2022-10-13T17:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zranger1](https://forum.electromage.com/user_avatar/forum.electromage.com/zranger1/32/301_2.png) [@zranger1](https://forum.electromage.com/u/zranger1)\
**Post date:** [October 13, 2022, 5:17pm UTC](https://forum.electromage.com/t/pixelblaze-client-python-library-release-updated-and-upgraded/2566/1 "2022-10-13T17:17:05Z")

</div>

With the addition of @pixie as a key contributor, I am pleased to announce the release of v1.0.0 - the first finished, non-beta version - of the [pixelblaze-client](https://github.com/zranger1/pixelblaze-client) library for Python.

This library presents an easy-to-use interface for controlling one or more Pixelblazes from a Python program. This version goes beyond the previous version’s control of run-time parameters and enables your Python programs to do virtually everything the Pixelblaze web interface can do. For instance, you can:

- Find Pixelblazes on your network
- Read and modify variables and controls in Pixelblaze patterns
- Back up and restore your Pixelblaze
- Work with EPE files
- Control Pixelblaze settings, including maps

and much more. See the [documentation](https://zranger1.github.io/pixelblaze-client/) for details.

In the course of this expansion, the API has changed. So if you’ve used the library before, take a look at the [documentation](https://zranger1.github.io/pixelblaze-client/) before upgrading. Chances are, you’ll need to modify existing programs to use the new library. But given the new capabilities available, it’s worth the trouble.

You can install the library from pypi: `pip install pixelblaze-client`

Source code, examples, complete API documentation, and additional instructions on installation and usage are available via the project’s [github repository](https://github.com/zranger1/pixelblaze-client).

And thanks @pixie, for turning the power up to 11! This is your release, and I am impressed, inspired and grateful.

---

<div class="post-metadata">

**Author:** ![pixie](https://forum.electromage.com/letter_avatar_proxy/v4/letter/p/7bcc69/32.png) [@pixie](https://forum.electromage.com/u/pixie)\
**Post date:** [October 13, 2022, 5:28pm UTC](https://forum.electromage.com/t/pixelblaze-client-python-library-release-updated-and-upgraded/2566/2 "2022-10-13T17:28:52Z")

</div>

The new version of the library came about because I was playing around with [rendering animated previews of patterns](https://forum.electromage.com/t/feature-request-raw-rgb-values-in-preview-jpg/1791/5) 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](https://forum.electromage.com/t/announce-a-few-pattern-management-tools/1942/17). Here’s what “Cube Fire 2D/3D” looks like on a variety of different layouts:

![cube fire 3D](https://forum.electromage.com/uploads/default/original/2X/0/0bf8858dbca4bef36bcc4fd8d802a4fcd64dae98.png) ![cube fire 3D](https://forum.electromage.com/uploads/default/original/2X/4/47a9f03574dbf7ac560e5de20b7251259507abf1.png) ![cube fire 3D](https://forum.electromage.com/uploads/default/original/2X/0/04004dc79ac1b9fad5a0cffb8aa8fa6e42873140.png)

 ![cube fire 3D](https://forum.electromage.com/uploads/default/original/2X/a/ae4939184ae36b8d147d8ac440a6b232e9a79479.png)

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:

```auto
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](https://forum.electromage.com/t/lightshowpi-and-others-integration-sacn-e1-31-proxy/766) and realized that the same technique could be used to serve _any_ kind of content to a Pixelblaze. There’s a [new example program](https://github.com/zranger1/pixelblaze-client/blob/1db1e878b70915fcc37bb7b74a88c6c8eabac6df/examples/animate.py) in the `pixelblaze-client` library that will play animated GIFs and PNGs onto a nearby Pixelblaze:

![pacmanGhost](https://forum.electromage.com/uploads/default/original/2X/8/81a2e87f73d99be484204c548dd8259d75b235c9.gif) =\> played to a 32x32 matrix =\>

 ![Pixel Proxy](https://forum.electromage.com/uploads/default/original/2X/b/bbfb4f34a5bd09f8b413207a047fbb6f237b7599.png)

…but what I really want, what I really really want is _video_. Fortunately, Python is the [duck tape](https://www.chicagotribune.com/redeye/redeye-is-it-duck-or-duct-tape-20151130-story.html) 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:

```auto
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](https://forum.electromage.com/uploads/short-url/8cCy657dGhznwqcvtsPhx1vlysA.py) (8.1 KB) and [playVideo.py](https://forum.electromage.com/uploads/short-url/2KcGV5H4NWIYrUGir4YeWuW4Z4N.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.

---

<div class="post-metadata">

**Author:** ![devoh](https://forum.electromage.com/letter_avatar_proxy/v4/letter/d/c5a1d2/32.png) [@devoh](https://forum.electromage.com/u/devoh)\
**Post date:** [November 20, 2022, 4:01pm UTC](https://forum.electromage.com/t/pixelblaze-client-python-library-release-updated-and-upgraded/2566/3 "2022-11-20T16:01:38Z")

</div>

and a bonus rickroll ! lol
