Converting video file to planar format.

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Converting video file to planar format.
by on (#127647)
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.
by on (#127663)
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.

Quote:
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.

Quote:
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.
by on (#127707)
Where can I get an avi file (or whatever format) for bad apple?
Re: Converting video file to planar format.
by on (#127713)
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.
by on (#127715)
You might also find “youtube-dl” useful.
Re: Converting video file to planar format.
by on (#127717)
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.
by on (#127720)
Thanks a lot!