Monday 31 May 2021

Why is this MPEG-4 compression of GIF creating weird results?

I was wondering what would happen if MPEG-4 tried to compress an image with completely random pixels. So I made an image with random pixels using Pillow in Python.

The actual GIF:

GIF frame sample

This isn't animated as the animated one was too big. The colour of each pixel is completely random. As MPEG-4 should only blend in colours which are similar. So, there should be a few blended colours due to colours being similar by chance. That's not what happened.

One of the MP4 frames: MP4 Frame

There is a CLEAR pattern in the compressing. It appears like a matrix of sharp, uncompressed patches and compressed blended patches. What's going on? The effect is way more clear in the .mp4 file which, click here for that. And it's even more clear in the original file stored in my device. This is not something that should happen with pseudo random numbers that Python generates through the random module.

All of the pixels in all of the frames were created through this:

[random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)]


from Why is this MPEG-4 compression of GIF creating weird results?

No comments:

Post a Comment