Photosensitivity warning: the videos on this page contain lots of flashing lights and colors.

What is Rastersong?

Rastersong is a project I've been working on for a bit over a year at this point. It originated as the result of a small and obvious realization: every bit of media that can be reproduced by a computer eventually boils down to a string of numbers.

Now, I can't really recall exactly what process of thought led up to everything, but I decided that it must be possible to convert a video file into a format that can be read by a DAW, such as my personal favorite, Reaper. Once that had been done, I could apply any audio effect, any arbitrary plugin such as reverb or delay, and see what that looked like on a pixel signal.

Soon after, I put together a small, sloppy Python program to convert video files into 8-bit .wav files. Aptly titled "vid-to-vst", it worked mostly correctly, and I was having plenty of fun loading videos into Reaper, mangling them up a bit, and viewing the results.

Well, viewing the results after about 2 hours of rendering.

Too much data

The issue with this approach is that Reaper and other DAWs are not built to handle the amount of data that comes out of an uncompressed video signal. For example, your average modern .wav file may have 44,100 or 48,000 samples per second, with a sample typically being a 16-bit integer (DAWs often work in 24-bit, or 32-bit float, internally). At 48,000 samples per second, 2 bytes per sample, and 2 channels for stereo, this comes out to:

48,000 × 2 × 2 = 192,000 bytes per second

Very reasonable, and you really don't get any more audible quality by going higher.

For video, however, we can take a modest 1920×1080 30fps video with 8-bit color, what you will see 99% of the time on YouTube or the like. To start with, getting the number of pixels per second, we multiply the pixels per frame by the 30 frames per second:

1920 × 1080    =  2,073,600 pixels per frame
2,073,600 × 30 = 62,208,000 pixels per second

Quite a jump from our .wav file from before.

Billy Mays pitching OxiClean in a TV ad, ending on the words “But wait, there's more!”Billy Mays pitching OxiClean in a TV ad, ending on the words “But wait, there's more!”

We've only gotten the rate of pixels so far, but what's in a pixel? Assuming it's standard RGB, we have three values per pixel: red, green, and blue. And as the name implies, 8-bit color means each of these colors gets an 8-bit representation. So, we get 3 × 8 = 24 bits per pixel, but let's just drop the 8, since a byte is 8 bits, and we don't really care about the lowly bit in this modern world. So, tl;dr, we multiply by 3:

62,208,000 × 3 = 186,624,000 bytes per second

Compared to our 192,000 bytes per second for 16-bit stereo audio, that's a 972× increase!

So, in the Reaper timeline, looking at 1920×1080 video as an audio format, every second of video becomes 972 seconds (16.2 minutes) of audio. A two-minute video is 32.4 hours of timeline! Insane!

Obviously, this is not an optimal workflow. Rendering out these videos, even at very very reduced resolutions, would take hours, and the worst part is you couldn't even see what the video would look like until the end. If you messed something up, you're screwed! Do it again!

A happy accident

I did a couple of videos for my friend using this painful approach, and they do have a very interesting datamoshed look to them. However, that's actually not intended.

intro, made for my friend's album.
iwillraponanything! by DBLE_T & MAiKAMAN.

When I made the first Python prototype converter, I forgot that 8-bit audio is not interpreted the same as 16-bit. 16-bit is signed; 8-bit is unsigned.

This essentially means that some parts of the pipeline thought that 0 was 0, and others thought 0 was 128. That's where that wacky colorization comes from: the colors are completely blown out.

I thought that was cool! So I made it possible to reproduce that behavior in Rastersong!

Getting to that, by the way.

Rastersong

Rastersong is my solution to all of the horrible steps of that previous workflow. It is a nonlinear video editor where formats go to die. Every supported format in Rastersong is internally just seen as a string of bytes, nothing more. The internal effects processor has (nearly) no concept of video or audio at all! It just takes in information and does whatever the heck it wants.

The Rastersong editor with no media loaded: a preview pane, a node graph, resources and an empty timeline.
Rastersong with an empty project. Preview on the left, the effects graph on the right, the timeline underneath.
The Rastersong editor with no media loaded: a preview pane, a node graph, resources and an empty timeline.

Now, making a nonlinear editor on its own is not a trivial task (working with FFmpeg alone was painful enough for me), but the nonlinear video editor part isn't really going to be discussed here. You can open videos, put them onto the timeline, chop them up, rearrange them, change their playback rate, and export it out to MP4 or your preferred format. Basically, it feels like baby's first Adobe Premiere.

The effects graph

The cool part is in the effects graph. In Rastersong you compose your effects as processing graphs. Everything bubbles up the timeline. With no processing graph on the timeline, the video and audio passes up to the master feeds as normal. Placing a processing graph above means their video and audio passes up into the graph, and then the graph exports the processed video and audio up again. You can stack as many processing graphs on top of each other to compose effects!

A Rastersong project with a graph track above a video track and an audio track. The preview shows a space scene recoloured in red and teal.
A graph track sitting above a video and an audio track. Everything below it passes up through the graph.
A Rastersong project with a graph track above a video track and an audio track. The preview shows a space scene recoloured in red and teal.

The effects graphs are created by connecting nodes to each other. For example:

  1. Take the video signal in from the input tap and plug it into an Amplitude Modulation node.
  2. Take the audio signal and plug it into the modulator tap on the Amplitude Modulation node.
  3. Plug the output tap of that node into the graph's video output.

Now the brightness of the video signal tracks the volume of the audio signal!

A node graph: the video is split into red, green and blue channels, the audio into low, mid and high bands, and each band drives an effect on one colour channel before they are recombined.
The graph from the project above. The lows drive distortion on the red channel, while the mids and highs modulate green and blue.
A node graph: the video is split into red, green and blue channels, the audio into low, mid and high bands, and each band drives an effect on one colour channel before they are recombined.

Or, even simpler, just plug the audio input directly into the video output to look at the sound, like some kind of cursed oscilloscope.

The audio input wired straight into a video output node. The preview shows grey horizontal bands of noise.
The song's audio wired straight into the video output.
The audio input wired straight into a video output node. The preview shows grey horizontal bands of noise.

(Almost) any control on a node can be modulated by an input signal. You can expose a modulation tap for a node parameter, and plug a signal into it as a control signal! Within the effects graph, any signal can be anything; you can plug anything anywhere anytime and see what kind of interesting effects it gives you.

A nice controlled example would be to take a kick drum input, and use it to control the distortion amount on the video signal. This would make the video signal boost up and start clipping whenever the kick hit, causing these cool rainbow colors.

On that topic, the optimal way to use Rastersong is not to take one flat video and audio file and mess with them, though of course that is supported. Instead, if you can, render out every track of your song separately and import them all as separate audio tracks in Rastersong. This lets you route each signal individually wherever you want, such as my example of the kick modulating distortion.

Real time, with a warm cache

This is all very cool in my opinion, and the best part of it all is that Rastersong can often run in real time, as opposed to needing 5 hours to visualize anything. Rastersong also has a very strong caching system that allows you to tweak parameters and see that frame update in real time.

Many effects used in DAWs have state. A reverb with a tail of 2.5 seconds, for example, requires the previous 2.5 seconds of audio to have run through it in order to give you the correct sound now. Most DAWs don't worry about this, for good reason (it causes laggy seeking), but what might be a subtly different sound in a DAW could be vastly different looking in Rastersong. As such, whenever you seek around in Rastersong, it warms up its cache first by invisibly rendering the past x seconds of video, always giving you an accurate representation at that frame. The maximum warm up time is configurable so you can also recklessly seek as fast as your heart desires.

wigs, a test demo made in Rastersong.

Rastersong is currently not available for public usage, as it is very messy and prototypish, but I hope in the near future it can be something that people can use in their video editing workflow!