# Convert video to 1 pixel per frame

Yes you read it correctly I want to convert a video file to a single RGB pixel per frame, so another way to think about it is that this one color per frame is the color you would see on your ceiling when you are watching TV… I am finding it not as easy as you may think… right now it close, but the RGB value when the 1 pixel video is played back I think it “flashes/blinks” too much as the algorithm tried to determine the color…

Anyone?? thanks!

2 Likes

What would that single frame color be?
The average of the brightness or what?
What outcome purpose do you expect?

2 Likes

Maybe you should explain what your current approach is? For example, are you computing an average RGB over the pixels array? are you using scaling, or a shader?

Depending on you area of appliication, you might be interested in bias lighting / ambilight / the adalight – there are privous Processing projects on this, for example:

1 Like

averaging gets you a very muddy result!

1 Like

looks like they are just looking at the perimeter colors and using them on the strip, the result would be OK, its way more complicated trying to get one color for the whole screen…

I tried designing algorithms based on the science of colors and our eyes, like how much each color adds to the overall perception of brightness is approx 60% G 25% R and 15% B, this gets you are good result, but when I calculate it and display it the color seems to change (flicker) too much compared to the video, one moment it picks bright white the next it shows blue… at the flick of a switch as the video pans from the sky down to the water… its a gradual thing but the one led flicks over from one color to another… so its not as easy as it seems…

1 Like

I expect to shine a very bright RGB led (just one) at the wall and playback the results and have it look like I am watching TV

1 Like

If you want to reduce flickering and smooth your color transitions, you can save the current color and lerpColor towards the new (flickering) target color. This will reduce the total possible color difference per frame.

Here is a barely modified Video > Loop example to illustrate the idea. It resizes each frame of the movie into a single pixel, then extracts color and makes it the target. The current color chases the changing target using lerpColor and a transition rate 0-1.0.

``````import processing.video.*;

Movie movie;
PImage img;
color target;
color current;
float transition = 0.5;

void setup() {
size(560, 406);
background(0);
movie = new Movie(this, "launch2.mp4");
movie.loop();
}

void movieEvent(Movie m) {
img = m.copy();
img.resize(1,1);
target = img.pixels[0];
}

void draw() {
current = lerpColor(current, target, transition);
background(current);
}
``````
2 Likes

WOW thanks so much, looks like just the conversion to 1x1 resize does the trick, I commented out the lerpColor() and displayed the video as it played with an overlaid patch of color and it behaves nicely!

Processing is very very useful!

Thanks!

2 Likes