Now that the emulator loads files at the same speed as the actual hardware, I decided to revisit video. This one is from the opening scene to The Spy Who Loved Me, including one of the greatest stunts ever recorded on film.
The video was extracted to bmp images, and those were compressed to 160x32 pixels, and then the closest color in a custom palette was found for each pixel. The color palette was not chosen for this video. It's a palette I'm using on another project, and most of the colors are based on the Wolfenstein 3D wall images.
These images are stretched to the desired 2.35:1 widescreen aspect ratio by setting the HSCALE to $20 and the VSCALE to $0F. The sound file was recorded in Audacity as 16 bit mono at 12970 Hz, and then cut up into files consisting of a 2 byte header and 2594 bytes of PCM audio data each. There are 10 audio files played per second. The video is shown at 15 frames per second at 5 kb each, so that's about 100 kb per second being loaded from the SD card and pushed to VERA. This should work on the actual hardware.
By the end of the video the audio and video are slightly out of sync, with the video lagging slightly. I could probably make the video and audio line up exactly if I dropped the video frame rate down to 12 frames per second, but that's getting into slideshow territory. I got the PCM audio figured out so that there's no bursts of static anymore; unfortunately the audio is so good that YouTube flagged it for copyright violation, even though the copyright owners do allow the use of it on YouTube.
I'm attaching a zip file containing BOND.PRG and the BOND folder, as well as the metadata files in the META folder. If you unzip this into the same folder as the emulator, it should work for you if you type
LOAD"BOND.PRG",8,1
RUN
If you also have the META/L editor, changing the BASIC bootstrap to 1 SYS$0400 will load up the editor and metadata so you can look at the code.
Are you loading the video with VLOAD or by loading into HiRam and then copying into VERA?
If you're loading directly to VERA, you can get a lot more speed by buffering it through HiRam first because under the hood, VLOAD uses the slow byte-by-byte load method and LOAD to HiRam uses block transfer mode.
Also - if you want to just stream from a single large file, you can do that as well - just don't use LOAD but instead make direct calls to MACPTR. See my thread here:
another video demo
Posted: Thu Aug 04, 2022 3:52 pm
by Ed Minchau
The 5kb image data files are loaded at $6C00, and the audio (2594 bytes) is loaded at $35DE. The last byte of the image is thus $7FFF and the last byte of audio is at $3FFF, so I'm just looking at bit 6 or 7 of the high byte for the end of data. I just used the regular LOAD; haven't touched sequential files yet.
another video demo
Posted: Thu Aug 04, 2022 4:18 pm
by ZeroByte
You should be able to squeeze a little more speed out of it doing that, probably about 2% - 5% faster I'd imagine. The overhead of opening a file is not trivial.
another video demo
Posted: Thu Aug 04, 2022 6:20 pm
by Ed Minchau
If I do another one of these it'll be with a couple sequential files. That 2%-5% would probably be enough to keep the video synched at 15 fps.
I'm just happy to see this working on an 8-bit machine at all.
another video demo
Posted: Tue Aug 16, 2022 7:58 am
by Wavicle
Unfortunately, the demo video hangs on the first frame on real hardware. There's an upcoming event where something like this playing maybe an excerpt from the "Building my Dream Computer" video would probably be very well received. Any idea on what the hang on hardware is or how difficult getting it to play a 1 minute bit of that YT video is?
another video demo
Posted: Wed Aug 17, 2022 3:50 am
by Ed Minchau
Is it playing any sound at all? The images should be getting loaded every fourth VSYNCH, but the audio is triggered by the AFLOW.
Also, did you try it on the emulator? Maybe I screwed something up in the upload.
another video demo
Posted: Wed Aug 17, 2022 7:55 am
by Wavicle
On 8/16/2022 at 8:50 PM, Ed Minchau said:
Is it playing any sound at all? The images should be getting loaded every fourth VSYNCH, but the audio is triggered by the AFLOW.
Also, did you try it on the emulator? Maybe I screwed something up in the upload.
I have not tried on the emulator. A video might do a better explanation than I could hope to do myself (warning: loud pops):
another video demo
Posted: Wed Aug 17, 2022 8:34 am
by Ed Minchau
The loud pops are the PCM running out of data. That shouldn't happen; when the buffer runs below 1kb the AFLOW flag is set, and in my custom IRQ when that happens the next 2594 bytes are loaded immediately. It's playing 12970 Hz 16 bit mono so 2594 bytes is 1/10th of a second being loaded when it still has 0.04 seconds of audio left in the buffer. And a new image should have been loaded every fourth VSYNCH. Very curious.
another video demo
Posted: Thu Aug 18, 2022 2:12 pm
by ZeroByte
It looks like it's not advancing the audio clip counter / frame counter and just repeating the same audio clip over and over.