Uzeamp Movie Player Demo

Use this forum to share and discuss Uzebox games and demos.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Uzeamp Movie Player Demo

Post by uze6666 »

Not much, it just streams movie data from a SD card. Resolution is 160x92 at 30 fps and sound at 15Khz. I guess another standard video mode like mode 1 could me added to provide menus...

Uze
Dosenpfand
Posts: 12
Joined: Mon Aug 25, 2008 7:48 pm

Re: Uzeamp Movie Player Demo

Post by Dosenpfand »

WOW!!!! great work!!!!!
can't wait to play own videos on my uzebox! will there be a howto to create the videofiles?
Cheers!
User avatar
pragma
Posts: 175
Joined: Sat Sep 20, 2008 2:16 am
Location: Washington, DC

Re: Uzeamp Movie Player Demo

Post by pragma »

Only 160x92? I could have sworn you had more vertical resolution than that. To think of what it would look like without doubling up the scanlines.

Optionally, leaving out every other scanline ala FMV for video games during the mid 90's might be another good way to fake high-resolution video.

So, who is going to work on the Uzebox port of Dragon's Lair?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Uzeamp Movie Player Demo

Post by uze6666 »

Only 160x92? I could have sworn you had more vertical resolution than that. To think of what it would look like without doubling up the scanlines.
Problem is you see, the SPI interface maximum speed is half the CPU clock. So each pixel is 18 clocks (16 clocks for shifting plus 2 overhead to start the transfer and read the byte). The active video part of scanlines is ~1495 cycles, so 1495/18=83 pixels horizontally. Now *that's* an abysmal resolution. I spent hours simulating frames at various resolution, color space and dithering types and trying to have a frame fit in a certain number of sectors. The 160x92 is the best I came up with. It's also the only one that went along the SD sector processing limitations. A video field is made of a sector for the sound (262 real data byte, plus the rest as a filler) plus the remaining sectors for the video. Each video sector contains 3 scanlines (or 6 half scanlines). So it means that in reality, a scanline is 170 pixels. the 10-15 first being black pixels to not screw up the video sync.

The way I used to double the horizontal resolution is to read the next video line's data (~160 pixels) in a buffer during two actual scanlines. Since those two scanlines are interlaced lines from a single field, they have to be repeated on the next field, hence the 92 pixels total vertical resolution.

I tough about putting two pixels per byte. Like that we could double the horizontal resolution, but still have the save vertical. In my tests that gave a weird aspect ratio to pixels and the look wasn't that great. Plus, the reduced color set and palette processing code in the main loop made things more ugly. In the same way, packing four pixels per byte we could get something like 320x224, put at only four colors per pixel, the resulting look would rather be poor anyways. We could develop some algorithm than extract a unique palette per-scanline and dither's accordingly with that palette.

Anyhow, this movie playing thing is very complicated and tricky. So far it would have to work on more than one SD card brand to be really worth something.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Uzeamp Movie Player Demo

Post by uze6666 »

Some asked me how to convert videos. Let's just say it's not for the faint of heart! There's no conversion tool per se, here's how I've done it:

Code: Select all

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:
  a)resize to 160x114
  b)Resize the canvas from the left to 170x114. This will produce 23pix wide black bar to the left
  c)Convert to paletted mode using the Uzebox palette, applying dithering of about %75
  d)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 to pack and interleave frames with audio.
5) Done!
Now, I'm 100% sure about those numbers, I'd have to look at the code. Also I don't think I've put the convertion tool under version control, so something else do to. About the file format it's worth noting that the file is really twice as big as it should since picture frames are doubled to fill both video fields with the same data.

-Uze
User avatar
JRoatch
Posts: 108
Joined: Mon May 11, 2009 11:48 pm
Contact:

Re: Uzeamp Movie Player Demo

Post by JRoatch »

Punching those numbers into a calculator didn't match up. So I went ahead and just opened the movie file with a hex editor. Here's what I found out.

Every video field takes 1 sector for audio then takes 38 sectors for video

An audio sector takes, as uze says, 262 single byte samples of audio that plays at 15750Hz (NTSC line rate), and 250 bytes of filler.
For video a scanline is 170 bytes. So a video sector has 3 scanlines plus 2 bytes of filler.
Now that means the video frame is 170x114 (38 video sectors times 3 scanlines), for sync reasons the leftmost 23 columns pixels is black. so then the usable viewport is 147 x 144.

Is this all correct?


Note: A sector is 512 bytes, if nobody knew that already.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Uzeamp Movie Player Demo

Post by uze6666 »

You are indeed right on! :D I crossed checked with my conversion tools and each frame is allocated 39 sectors (38 video+1 sound). So all the other numbers are right. The story of this arrangement is simple. After reading each MMC sector, you must read a 2 bytes checksum. You can understand that this is not possible during the visible rendering part, so I aligned the reading of those two byte during the HSYNC. That's why I have 3 lines of 170 pixels per sectors. Each 3 scanlines (during HSYNC) the two last sector bytes and the checksum bytes are read plus 2 more "data ready" bytes. These are required on the cards I had and appears to be the minimum latency between two sector reads. Unfortunately, some other cards I had had longer latencies so for those, the picture will get screwed up. I couldn't figure out the reason or relationship between brands to explain this.

-Uze
User avatar
JRoatch
Posts: 108
Joined: Mon May 11, 2009 11:48 pm
Contact:

Re: Uzeamp Movie Player Demo

Post by JRoatch »

Did some more calculations.
When I converted "8-bit trip" (about 229.12 seconds) to a image sequence with ffmpeg at ntsc field rate, I got 13731 fields.
Now each field needs 262 samples for audio. That comes out to 3597522 samples for a 229.12 second track.

3597522 / 229.12 = 15701.475209497, or for simplicity 15700 Hz.
according to wikipedia, the ntsc line rate is 15734.26 Hz.

I guess this has to do with the missing half line? :?

Anyway I'm going ahead with the encode. What would be a good place to upload it once I'm done?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Uzeamp Movie Player Demo

Post by uze6666 »

I guess this has to do with the missing half line? :?
Yeah, that's a problem. My vids so far, all gets progressively off sync after a minutes or so. I guess the assembling algorithm should duplicate or remove video frames to keep pace with audio.
3597522 / 229.12 = 15701.475209497, or for simplicity 15700 Hz.
according to wikipedia, the ntsc line rate is 15734.26 Hz.
If you can do that with ffmpeg, try exporting at 30fps (instead of 29.97fps). Your ratio should get closer to 15717hz.

Btw, also export with frame deinterlacing enabled. That should give a better picture because otherwise the interlacing will be much evident since line are quadrupled.

As for the upload, PM me when you done we'll coordinate an FTP upload on my site.

-Uze
User avatar
JRoatch
Posts: 108
Joined: Mon May 11, 2009 11:48 pm
Contact:

Re: Uzeamp Movie Player Demo

Post by JRoatch »

Apparently imagemagick messes up the palette in one way or another. :(
What program should I use? I don't have photoshop, and I don't feel like manual converting 3,000,000+ images to the correct palette in GIMP.

I was kind of hoping I would of got it done during this break. Oh well.
Post Reply