Page 1 of 1

Converting video file to planar format.

Posted: Fri Apr 11, 2014 12:13 pm
by psycopathicteen
I looked for a program that could convert video files to planar format that can be used in SNES games, but I couldn't find any, and I'm only starting to learn C++ and I don't want to reinvent the wheel.

This has to do with the "bad apple" demo I've been wanting to make. I'm pretty much finished with the compression algorithm in asm. I just need a compressor for the following format:

The data stream alternates between compressed tile maps and compressed 2bpp tile patterns, with the compressed tile map always first.

Tile maps are compressed with 1 byte for each group of tiles.

00xxxxxx = x many white tiles in a row
01xxxxxx = x many black tiles in a row
10xxxxxx = x many 2bpp patterned tiles in a row
11xxxxxx = same as above

After the compressed tile map data is the compressed tile patterns.

The first 16-bit word, has each bit corresponding with a row of 8 pixels for the first 2 8x8 tiles, followed by the rows of 8 pixels themselves.

0 = repeat last row of pixels
1 = fetch new row of pixels

...and the pattern repeats.

Re: Converting video file to planar format.

Posted: Fri Apr 11, 2014 2:57 pm
by tepples
psycopathicteen wrote:I looked for a program that could convert video files to planar format that can be used in SNES games, but I couldn't find any, and I'm only starting to learn C++ and I don't want to reinvent the wheel.
TIP: Start by using FFmpeg to decode the video, convert it to grayscale, scale it to 256x224, and output a stream of raw grayscale pixels. It'll give you a stream of pixels, and you can quantize them to 4 grays and do the compression in your own program.
Tile maps are compressed with 1 byte for each group of tiles.

00xxxxxx = x many white tiles in a row
01xxxxxx = x many black tiles in a row
10xxxxxx = x many 2bpp patterned tiles in a row
11xxxxxx = same as above
I'd recommend using 10xxxxxx for 1bpp patterned tiles, with a tunable parameter "lossiness" in the compressor that adjusts under what conditions 1bpp will be used.
0 = repeat last row of pixels
1 = fetch new row of pixels
That is almost exactly the same RLE scheme that I used for CHR data in the Action 53 multicart and my entry to the second compo, except I compressed each bitplane separately, and the sense of the bit was inverted (1=repeat, 0=fetch).

Re: Converting video file to planar format.

Posted: Sat Apr 12, 2014 7:29 pm
by psycopathicteen
Where can I get an avi file (or whatever format) for bad apple?

Re: Converting video file to planar format.

Posted: Sat Apr 12, 2014 9:51 pm
by Joe
I downloaded a copy of the video from Niconico on October 14th, 2010. I can send it to you in a PM if you'd like.

Re: Converting video file to planar format.

Posted: Sun Apr 13, 2014 1:17 am
by lidnariq
You might also find “youtube-dl” useful.

Re: Converting video file to planar format.

Posted: Sun Apr 13, 2014 3:05 am
by Stef
I have the original bad apple video exported frame per frame in BMP image as i needed it to do the megadrive version of the demo.
I made some specific versions which suit more to your needs :
256x192 resolution in 8bpp: keep pixel ratio and you have some extra blank lines if needed.
256x224 resolution in 8bpp: full screen

You have a sharpen version (default one) and a smooth filtered version (_smooth) so you can make some tests and keep the one you prefer. Just for information on megadrive i used sharpen version to get better compression (i also used only 4 levels of gray).
Here is the link to download them :
https://www.dropbox.com/sh/kyvjzvnj1q4f ... pple/video

Re: Converting video file to planar format.

Posted: Sun Apr 13, 2014 2:32 pm
by psycopathicteen
Thanks a lot!