Mode 7 Encoding

From Uzebox Wiki
Jump to navigation Jump to search


uzebox palette
The palette for the uzebox

Video mode 7 is dedicated to stream raw video data from an SD card. So you want to put a video onto the uzebox using Mode 7? There are several ways to do it but here's the general outline

  1. convert your video into an image sequence that is 147 x 114 pixels, one byte per pixel, uses the uzebox palette, and has a rate of about 60 images per second.
  2. convert your audio into an uncompresed unsigned 8-bit PCM wav file at NTSC line rate (15750Hz).
  3. multiplex the raw data togeter according to Mode 7 Implementation Details

Uze's Method

  1. In Adobe Premiere extract frames to numbered BMP files & extract sound track to a WAV file.
  2. In Photoshop make a batch process to read the BMP files an apply the following transformation:
    1. resize to 147x114
    2. Resize the canvas from the left to 170x114. This will produce 23pix wide black bar to the left
    3. Convert to paletted mode using the Uzebox palette, applying dithering of about %75
    4. Save picture as RAW file 8bpp, no header
  3. In CoolEdit pro (sound editing software) convert the soudtrack to 8bit mono 15750Hz, save a raw signed
  4. Use my java tool (unavailable) to pack and interleave frames with audio.
  5. Done!

JRoatch's Method

  1. Extract the video frames into an image sequence using ffmpeg.
    ffmpeg -i ../8bit_trip.mp4 -r 60000/1001 -s 146x80 -f image2 frame%05d.png
  2. Process images using imagemagick, and turn them into portable pixmap files.
    mogrify -gravity East -background black -extent 170x114 frame*.png
    mogrify -map ../color_table.png -format ppm *.png
  3. The audio probiably could have been extracted by ffmpeg, but I used Quicktime on a mac to extract the audio to 15700hz. 15700 because I belive that fits better with the Mode 7 Implementation Details.
  4. multiplex the data using a quick c program I wrote.
    ./mode7multiplexer output.dat audio.wav frame*.ppm

Nebososo's Method

This method is based on JRoatch's, not only it is completely scripted, but it won't generate black bars on the top. I haven't tried, but I believe it can be easily adapted to windows. It also supports any format ffmpeg does.

  1. Save the color table to any folder you like.
  2. Compile JRoatch's Multiplexer, rename it to m7m and put it in the same folder.
  3. Save the script I wrote in the same folder and chmod +x it.
  4. Run the script as in the example: ./touzm novijgod.avi ngod.uzm
  5. Copy the uzm file to the beginning of the SD card (before all the uze files), if you put it in the end, the image will be messed up. (I have a script to format the card, copy the wavs first, then the uzms and, finally, the uzes)