Bad Apple! / Compressed video proof of concept

Bad Apple rocks, I used it for testing an oled using mplayer on a Pi a few years ago.

I happened to stumble on this arduino running Bad Apple on an ssd1306 there’s a link to the bitmaps in the description


I had no idea that you can use he x3key remote in that way :nerd:

1 Like


FMV looks so good!!!

I wish @bateske would hurry up and make an Arduboy with an SD card! Oh wait, thats me. :flushed:


I held off on buying one specifically because I heard they were making a better Arduboy with an SD card slot. That was around christmas time I think :P, I’ve been ‘borrowing’ my friend’s kickstarter unit since before then.

A modified version of gif might just compress a video small enough to fit some quality seconds. Dividing down the rez would allow for more time, and if you don’t do it quite as much the video might be discernible. gif format would have to be redesigned to take advantage of the framebuffer order. I think gif patent ran out and there is likely example source out there either way. I believe the gif animations are mostly diffs so only a fraction of the frame is being compressed along with vectors. One could likely compress the 1 bit frames in an ordinary gif and find out how much space it should take.

In the mean time, one could consider pulling in data from a PC via USB using the Serial functions.

The gif format has too much guff.

The header block wastes 6 bytes, the logical screen descriptor is 7 bytes and uses 16-bit numbers (when realistically the Arduboy would only need 8 bits describing the image width and height), then it has an optimal global table which requires at least one byte to indicate that it’s been disabled, et cetera et cetera.

Long story short, it would be more efficient and probably easier to just use an entirely custom-made format that takes all the Arduboy’s limitations into account. All it would need to be is a series of (compressed) frames with a list of timings indicating which frame is to be displayed next and for how long.

1 Like

I think a modified version of the format might work. Since the payload should be modified so should the headers. One could even go so far as to assume we are dealing with arduboy and forgo the traditional header. Use an index into constant array to define header details. Decoding builds string tables which are likely going to be where one sees memory concerns.

I was thinking one could get better results replacing the string table compression with Huffman coding. I don’t see any reason why the table couldn’t be stored in PROGMEM so that would lower processing overhead Not that we are suffering from a lack of processor power. :laughing: It would avoid cluttering ram. Actually thinking about it making use of ram would be better for compression tables as well as generating them on the fly from data like gif does.

I think the most important part of any video format for the Arduboy is storing/compressing diffs avoiding whole frames as much as possible. There is going to be a threshold where storing diffs will approach the size of a full frame so those might as well be full frames.

1 Like

Searching for 1 bit animated gif didn’t yeild much results. Well except source.
If I had the frames I could try it so see what size one could potentially get. Even the example is close to 32k and that is a 4bit gif. So I believe there is potential.

1 Like

It’s a bit of a Thesseus’s Ship paradox though.
Once you scrap the headers, the unnecessary 16-bit stuff, the colour table etc can you really say it’s based on gif anymore? At some point when you’ve removed enough features its effectively an entirely different format that doesn’t resemble gif anymore, at which point it might as well have been its own thing in the first place.

If you start from scratch and pluck the best bits of several different image formats you’ll end up with a better format overall. For example, PNG’s deflate algorithm (which is combination of huffman coding and LZ77) is typically much better than GIF’s LZW.

Without running tests though it’s impossible to say which method will work best. It might be the case that RLE works better than any of the fancier compression methods.

Be careful what you wish for.


I may take a crack at a video demo when I’m done with the project I’m working on now. I don’t see video being practical for a game without external storage, but it is still a fun problem to mull over.

1 Like

I experimented with some frames we used to make the video for our game jam submission. I was able to get 207 frames down to about 24k with gif. And for lolz I 7ziped it. I think we might be able to come up with some worthwhile video compression if the 7zip source isn’t insanely huge. I know it is processor intensive, but we have way more processor than available space so…

1 Like

The 7z format supports LZMA, LZMA2, Bzip2, PPMd and DEFLATE as well as AES-256 encryption, unicode file names, various preprocessing features et cetera et cetera. There are 99 files alone for the different compression methods.

“I’ve got 99 files, but not a glitch in one.”

Seriously though, I think a custom file format would be much better.

I might work on a prototype myself later in the week, but I’ve got other projects on the go and there’s voting to be done.


Inspecting the archive it claims to only be using LZMA:16 to compress the gif.

1 Like

I did a hard work to create an image compression library for arduboy ( Unfortunately only few people knows about it. :pensive:

After cropping the gif to the visible 64x64 pix and using the compressor I had these results:

// File: bad2.gif (207 frames)
// Size: 207x64x64px (105984 bytes)
// Compressed: 13696 bytes
// Ratio: 0.12922706

Sketch uses 22,014 bytes (76%) of program storage space.

Sketch can be generated with one command line.
Please, ask me if you have any issue with the lib. Thanks!


Write and article about it for the Arduboy Magazine. That may get more people interested in using it.


is somewhere a final code for full “bad apple” animation on Arduboy )

Holy necropost batman, an image compression algorithm?

This combined with the FX chip could be quite epic. @Mr.Blinky What do you know? :wink:

1 Like

The demo was a quick and dirty play raw frames from flash. Maybe I should make a real demo with out of it?

You don’t want to know what i know :wink:

1 Like

Yah but compressed video!

I dream of seeing a new hope on arduboy!