Blending Tracks

Blending tracks together is a great way to add complexity to your scripts without having to write too much code. You can use the blend key in the clips array to set the blend mode for any clip. In the example below, we add a screen layer on top of our entire composition.

import * as hypno from './stl.js'

// Screen Blend Demo

const mainTrack = composition.track("main")
const screenTrack = composition.track("screen")

hypno.buildTimeline({

    fps: 30,
    resolution: new Vector(960, 1280),
    clips: [
        {
            // we're going to omit the asset key so the 
            // track defaults to the camera input
            start: 0,
            duration: 30,
            track: mainTrack
        },
        {
            start: 90,
            duration: 80,
            track: mainTrack
        },
        {
            start: 43,
            duration: 40,
            track: mainTrack
        },
        {
            start: 55,
            duration: 50,
            track: mainTrack
        },
        {
            start: 0,
            duration: 200,
            track: screenTrack,
            asset: new Asset("./filmGrain.mp4"),
            blend: hypno.blend.screen
        }
    ]
})

Here's what the timeline looks like for the script above in Nyx.

And, here's the output:

Hypno script supports most commonly used blend modes, and you can find a full list here.

Now, let's move to a more complicated example to review some sequencing techniques. Say, for example, you only want to have a blend over the second and fourth clips on the mainTrack of your composition. And, let's assume you want to use different sources as the blend layer at different points in the script. In this case, you could make two clips on the screenTrack , give each a different asset, and line them up with the second and fourth clips using insert.

import * as hypno from './stl.js'

// Blend Demo 2

const mainTrack = composition.track("main")
const screenTrack = composition.track("screen")

hypno.buildTimeline({

    fps: 30,
    resolution: new Vector(960, 1280),
    clips: [
        {
            // we're going to omit the asset key so the 
            // track defaults to the camera input
            start: 0,
            duration: 30,
            track: mainTrack
        },
        {
            start: 90,
            duration: 80,
            track: mainTrack
        },
        {
            start: 30,
            duration: 40,
            track: mainTrack
        },
        {
            start: 0,
            duration: 50,
            track: mainTrack
        },
        {
            start: 0,
            duration: 80, //the same as the second clip on the mainTrack
            insert: 30, // where the second clip starts
            track: screenTrack,
            asset: new Asset("./filmGrain.mp4"),
            blend: hypno.blend.screen
        },
        {
            start: 0,
            duration: 50, //same as the fourth clip on the mainTrack
            insert: 150, //where the fourth clip starts
            track: screenTrack,
            asset: new Asset("./lightLeaks.mp4"),
            blend: hypno.blend.screen
        }
    ]
})

Here's what the timeline & output look like for this example:

Last updated

Was this helpful?