Newbie help: how to use multiple clips from one video source over another

Hi, so, I’m a complete beginner. I’m trying to create a template with one video that runs all the way through (VIDEO1), and then on top of it at various times, different length clips from a single different video (VIDEOA).

So a simplified version of the end product looks like:
VIDEO1 for 30 secs
VIDEOA for length 3.5 secs from position 36.2 secs of VIDEOA
VIDEO1 for 12.4 secs
VIDEOA for lnegth 2.2 secs from position 12.7 secs of VIDEOA
VIDEO1 for 17 secs

At the moment, VIDEO1 is on one track and I want clips of VIDEOA covering it, so I assume merge fields, and then I want to be able to replace VIDEOA with VIDEOB, VIDEOC etc, for separate end products.

I’ve read how to set the properties of the VIDEOA clips in the code (asset type, src, start, length, etc) but I can’t work out how to add a merge field kind of “over the top” of the other video. I was assuming I add this as a second video track, but how do you add merge fields to that?

Once I know what I’m doing, I also want to use chromakey to overlay parts of VIDEOA over VIDEO1, so I don’t want to resort to alternating them on the same track.

Can anyone show me some code which has two different video tracks,with some merge fields, please? Or tell me how to acheive the above?

Then I need to understand audio. Can I use the audio from VIDEO1 all the way through, but add the audio from VIDEOA to it in some clips (so like 50:50 mix), and leave just the VIDEO1 audio in others,with VIDEOA muted?!

Thank you for any assistance…

Let me help you with this step-by-step. You’re on the right track with your approach!

Overlaying clips using merge fields

Here’s how to set up your template with VIDEO1 as the background and VIDEOA clips overlaid at specific times:

{
  "timeline": {
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "video",
              "src": "{{videoA}}",
              "trim": 0,
              "volume": 0.5
            },
            "start": 4,
            "length": 3,
            "scale": 0.5
          },
          {
            "asset": {
              "type": "video",
              "src": "{{videoA}}",
              "trim": 10,
              "volume": 0.5
            },
            "start": 8,
            "length": 3,
            "scale": 0.5
          }
        ]
      },
      {
        "clips": [
          {
            "asset": {
              "type": "video",
              "src": "https://shotstack-assets.s3.amazonaws.com/footage/beach.mp4"
            },
            "start": 0,
            "length": "auto"
          }
        ]
      }
    ]
  },
  "output": {
    "format": "mp4",
    "resolution": "hd"
  },
  "merge": [{
    "find": "videoA",
    "replace": "https://shotstack-assets.s3.amazonaws.com/footage/drone-car-overhead.mp4"
  }]
}

You can see how chromakey works in the docs and this can also be configured in the Studio by enabling chroma key in the video clip settings panel.

For audio your approach to audio is correct:

  1. Keep VIDEO1 audio playing throughout (base track)
  2. Add VIDEOA audio during overlays with reduced volume (set to 0.5 in example)
  3. To mute VIDEOA in some clips, set "volume": 0 for those specific clips

The downside of this approach is that the audio will “suddenly” change volume so you’d want to use a keyframe or effect to smoothly cross each clip into each other.