Tuning Retro Video Archives for Display on the Modern Web using WebGL in React

Rate this content
Bookmark
Slides

- Background on why retro video archives need custom scaling

- Implementing a WebGL video player canvas in React with custom hooks

- Bundling WebGL shaders from separate files for GLSL syntax highlighting

- Live Demonstration of applications for footage from retro video game consoles, VHS tapes, etc

FAQ

TaskBot functions like a player piano for retro game consoles, executing pre-programmed speedruns on systems like the NES, SNES, and N64. The TaskBot team translates tool-assisted speedruns into sequences of inputs that are then played back on the original consoles, replicating these runs with precision.

The main challenges include chroma subsampling which reduces color data, handling small resolutions and non-square pixels of old games on modern displays, the use of lossy compression in web videos, and preserving the intentional visual effects of CRT displays in digital formats.

The Area scaling algorithm is used to upscale pixel art footage accurately. It helps preserve the sharp transitions between different colors typical in retro games, avoiding the blurring that occurs with bilinear interpolation, thus maintaining the visual integrity of the original game art.

RGBScaler.com uses advanced scaling algorithms and techniques to preserve and enhance low-resolution retro gaming footage. It allows users to experience games with visual fidelity close to the original by simulating CRT effects and using precise scaling methods like the Area algorithm.

RGBScaler.com supports AV1 and H.265 codecs. AV1 is used for its support for 444 color and lossless footage, ideal for archival purposes, while H.265 (or HEVC) is supported mainly for its efficiency and compatibility with iOS devices.

WebGL is used on RGBScaler.com to bypass the limitations of HTML5 video elements, which often use bilinear scaling. WebGL allows for the implementation of more sophisticated scaling algorithms like Area, which are better suited for the unique demands of pixel art and retro game footage.

Travis McGeehan
Travis McGeehan
31 min
06 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Travis Tykemany3 McGeehan, a full-stack developer at Gordon Food Services and an administrator for the TaskBot team and ambassador from Task Videos, discusses preserving retro game footage from the TAS scene for modern viewers with WebGL. He explains the role of TaskBot, a player piano for retro game consoles, and how the TaskBot team translates tool assisted speedruns to create the fastest possible sequence of inputs. He also highlights the core problems in video game footage archival, including chroma subsampling and stretched aspect ratios in small resolutions. Challenges in retro game footage preservation include storing records at the original, unstretched resolutions and avoiding bilinear interpolation. Different algorithms, such as point and Area, produce distinct effects when scaling up images. Techniques used on rgbscaler.com to preserve crisp footage of low-resolution GameBoy games include the use of the area algorithm, AV1 and H265 encoded videos, and the ability to play videos with CRT effects. The AV1 and H.265 video codecs are used to support lossless footage and proper upscaling of pixel art footage. A custom canvas with custom controls is created using React to blow up the video in WebGL, and the area scaling algorithm is used instead of bilinear. The WebGL texture updates using a render loop, and the shader logic recreates the mask and scan lines based on pixel position. The React RGB Scaler library enables syntax highlighting for the vertex shader and the fragment shader, making development easier. The RGB scaler site demonstrates the value of improving video quality while using significantly less bandwidth than YouTube.

1. Preserving Retro Game Footage with WebGL

Short description:

Travis Tykemany3 McGeehan, a full-stack developer at Gordon Food Services and an administrator for the TaskBot team and ambassador from Task Videos, discusses preserving retro game footage from the TAS scene for modern viewers with WebGL. He explains the role of TaskBot, a player piano for retro game consoles, and how the TaskBot team translates tool assisted speedruns to create the fastest possible sequence of inputs. He also highlights the core problems in video game footage archival, including chroma subsampling and stretched aspect ratios in small resolutions.

Thanks, this is Travis Tykemany3 McGeehan. I'm a full-stack developer at Gordon Food Services and an administrator for the TaskBot team and ambassador from Task Videos. I'm also a TAS author, so I just said the word TAS a whole bunch of times. You guys are probably wondering right now, what is a TAS? Well, that's the first thing we'll get into talking about preserving our retro game footage from the TAS scene for modern viewers with WebGL.

So this is who is the TaskBot and what is the TaskBot team? TaskBot is like a player piano for retro game consoles, particularly the NES, SNES, and N64 era consoles with help from the Game Boy interface on the Game Boy. The TaskBot team helps translate tool assisted speedruns, playing video games as fast as possible with the assistance of tools to go back frame by frame through those video games and create the fastest possible sequence of inputs. And then we take those trends and translate them to the original consoles and like I said, like a player piano, put those inputs through into a real console. So we've done all sorts of showcases for this at MAGFest and Games Done Quick, requiring precise video capture. And that kind of gets into the talk more directly about the tools we're using for that precise video playback and capture on the web.

Just a word of caution, the discussion here is going to be mainly relevant to this sort of retro video archival and tune towards animated footage, especially in these very, very ancient video games. It'll be less relevant if you have live filmed video, except when we're trying to transmit an archived copy of such video over the web. So there's a bunch of core problems we see in video game footage archival when we're trying to document these records of speedruns on TAS videos. The first one is chroma subsampling, just super high-level, that is color reduction. In all the modern video codecs, they take the color aspect of the data and split it from brightness, and because of that split that goes all the way back to the difference between black and white and color televisions, the game consoles were not originally doing that split. They were just outputting full color information alongside brightness information, and when they get shoved into a more modern video codec that has that split, they lose some of their data and you get worse video, especially at these very low game resolutions like 240p. If you only have half the color data from 240, now you're only talking about 120 lines of color and that's not very much color. So this didn't really happen with sub-sampling in video games until the GameCube era. So these really old video games where we're doing these speedrun records, often in the NES to N64 era, we don't see this color reduction being baked into the games, and then we do see corruption of the video footage.

The second problem we have is these super small resolutions having stretched aspect ratios. So these are also very small resolutions just to start with, and we have to get them upscaled to modern displays. So we talk about displays like the OLED LG G3, or the Samsung S95B, or all sorts of... now they're coming out with actual gaming monitors for these extremely color accurate displays. We want to be able to show on those displays, but we can't necessarily do that at the original resolutions. Because these displays are like 1440p or 4K. So we have to stretch up to the full display. And then we also have this issue of the original games resolutions were not square pixels. When they played back on CRTs, CRTs played every single input as a 4-3 source. So if the game coming in was 256x240, like on the NES and was nearly like a square image, it would be stretched out to being a rectangle on the resulting CRT display. So we need to replicate that stretching on the monitor. But if you do that when you store the footage, so let's say you made an NES video and you stored it at 320x240, you would get weird artifacts where you'd have maybe a pixel that looks right, and then the pixel to the right of it is halfway between two, and now you have an artifact there.

2. Challenges in Retro Game Footage Preservation

Short description:

So you want to store records at the original, unstretched resolutions and avoid bilinear interpolation. Lossy compression and intentional CRT corruption in retro games pose challenges. Different algorithms, such as point and Area, produce distinct effects when scaling up images.

So you want to be able to store these records at the original, unstretched resolutions of the 256x240 and then doing that stretch out to the 320 when you get to the final display resolution like 1440 or 4k. We also have a problem where when we do that upscaling in the normal video codec, or normal video player, the HTML5 video player, it does everything in a algorithm called Bilinear, which is really great for film footage, where if you wanted to interpolate between one pixel and the next, it would make sense to just average the two. But in a sort of pixel art video game sense, you don't want to have all those extra bits of color. In the original video game, it went straight from being one color to the next color. So it doesn't work to do that sort of bilinear interpolation. It might use other algorithms for pixel art instead.

Fourth, we have the issue of lossy compression. Almost all web videos are lossy, which means there's a bunch of artifacts just into the compression to be able to make them transmittable over the web. So we have our own set of techniques to be able to do lossless stuff for these very ancient and smaller videos. And then fifth, we have a, and lastly, we have this CRT and composite video signal intentional art design. So a lot of these original NES, SNES games, they weren't just developing the signals to be like, okay, we're just going to show you this image. They were actually developing it, intending it for it to be corrupted the way that a CRT would corrupt an image just like even these really, really advanced 4k and 1440p color accurate monitors still have slight corruption to images. Back then CRTs had a lot of corruption and this corruption was used to create extra colors, like using dithering or you would have a checkerboard pattern to then gradient between two colors and have actually more color than the system itself could create available by taking advantage of the artifacts caused by the CRT.

So with all of those problems in mind, let's just see what some of that looks like in practice. So this is what I talked about with the bilinear smoothing, that's the middle one of this comparison. That is how almost all videos are played if you just watch a video online like YouTube, Twitch, all of them are going to have that filtering on them to get them up to the size of your browser. On the left, you can see a different algorithm called point. Between the top and bottom, you see differences in two different successive frames of a video. So on the top frame, Link's shield in this image is on one pixel, and on the next frame it's on a different pixel. And because of how point works, it's going to be wider on one of those frames than the next frame if you happen to be scaling up by a non-integer factor. So let's say your source is 240, like on the NES. And you're going up to, not 960, 4 times, but 1080p, a normal desktop resolution, 4.5 times. And if you go up from one source pixel, 4.5 times, well nearest neighbor, or point, says you can only go up by 4 or 5 times. So that's why in one frame of video on the top, it's gone up 5 times on Link's shield, and then on the bottom one, on the next frame, it's moved over, and now it's only going up 4 times for that line. Because over the source of the whole video, each vertical line is either going to be 4 or 5, back and forth. And this creates like, a sort of shimmering and waving effect. And on the right of the three, you see Area, which is the algorithm we like to use for this sort of extreme accuracy reproduction, where it's kind of like the Mercator projection. In the Mercator projection, when you're talking about maps, you have all this distortion of the shapes of continents, because of trying to make things straight latitude and longitude, and that's what we saw in Point. Whereas Area is trying to compromise between having straight longitude and latitude, and having proper shapes. So Area has a proper shape of the shield, it's always the same number of pixels wide, and that's because if we were going up like four and a half times, it would have four regular pixels, and then for that half, it would go back to doing bilinear and averaging just for that one line where it needs to.