How to place a still object behind a moving object? (Please help!)

0xmethodic Posts: 4 Just Starting Out*
edited September 2021 in Post-production techniques

Moved this to the Hitfilm community support thread- below post explains my question.



  • 0xmethodic
    0xmethodic Posts: 4 Just Starting Out*

    Hi All, I'm new here and I'm trying to teach myself how to do some basic video editing.

    I want to make an edit where a still object is placed behind a moving object. The actual screenshot is below...

    The character is walking from left to right and stops in the middle and I've added the pink image on top of the original video.

    What I've tried so far:

    1. Tracking the character from left to right - I was able to track successfully and tested out attaching some text as he walked across. But I'm just so confused with how to attach a mask or if that is the right way to go about it. I've looked everywhere on the internet but couldn't find any examples of this.
    2. I tried to mask the head of the character in duplicate video manually i.e. mask the head and select position and drag the mask across with each frame. Every time I do this, the whole image also moves with the mask and I don't know how to keep the image still whilst moving the mask. 

    Can someone please help me or point me towards a tutorial that shows how to do this? I'm a total beginner but have tried over several hours (pretty much half of the whole day) trying to figure this out on my own :(

    Many thanks in advance!


  • Andy001z
    Andy001z Lord EarthPosts: 3,498 Ambassador

    Hi you need to learn how to use the keyframes in Hitfilm. It's pretty powerful,

    Check out

  • Triem23
    Triem23 Posts: 20,190 Power User

    Ok, you've figured out you need to "mask" or Rotoscope Stewie's head, but let's discuss "masks" vs "mattes."

    A mask uses data drawn on layer "A" to define a transparent area on layer A.

    A matte uses information on layer "B" to define a transparent area on layer A. The matte can use data from a choice of channels - Red, Green, Blue, Luminance, Alpha, etc. In general most mattes are designed to use data from Luminance or Alpha to drive a single transparency. You can use colored layers to embed multiple mattes in a single image, but that's advanced work.

    I haven't watched this particular tutorial yet, but I'll assume it's helpful.

    Here's an old Javert tutorial from before he worked for FXhome that's a good basic talk on Set Matte.

    And my own tutorial, which gets into masks, mattes and keys and the differences/similarities between all. This tutorial was done in Hitfilm Pro 2017, so the section on Mask controls is now obsolete (mask controls have changed), but the principles are correct.

    The FilmSensei tutorial Andy linked above is current, so it shows the proper controls for HF 2021.

    Ok, intro aside, now we can talk about your issue.

    You can't track a mask. The data on the mask is embedded in the image layer. You've already encountered this. The mask itself would have to be animated, and, with Stewart bobbing up an down and his head wiggling from side to side, that's a pain.

    However, you can track a LAYER, and, since a Matte uses layer B to apply transparency to Layer A, creating a MATTE layer is the way to go.

    You'll need to track two points on Stewie. Probably his eyes. You'll create a white plane layer, put it above Stewie, set its opacity to something like 25% (you want to see Stewie under the plane, but want to be able to see where the plane is. then mask the plane to Stewie's head. Then parent the plane layer to the tracked point.

    Now the plane will follow the track. If Stewie doesn't turn his head left to right you might be done. You might still have to animate the mask, but, since the plane layer is tracked, it'll be a lot easier since the track is handling the motion.

    Once the mask is roto'd you can turn its opacity up to 100%, select the plane layer, move it all the way to the bottom of the layer stack and add a Grade Layer just above the plane. You'll need this Grade Layer for the next step.

    Ok, now DUPLICATE the Stewie video and put this ABOVE your insert. Add the Set Matte effect to this top copy, use the Grade Layer as the Source Layer, the Matte Source to Alpha and the Blend to Replace.

    Stewie's head should now be above the insert.

    Why are we using the Grade Layer? Effects in Hitfilm using a "Source Layer" look at the "raw state" of a layer. The raw state is the layer before effects and masks are added, so, if you used the plane layer as the Matte Source the Set Matte effect would see a perfect white plane. A Grade Layer renders everything below itself first, so the "raw state" of the Grade is that render. This means the Grade Layer "bakes in" the mask on the plane, so the Set Matte sees it. You could also convert the Plane Layer and its tracked point to a Composite Shot which would also bake in the transparency.

    Film Sensei has this tutorial, which will cover, in video, what I've discussed here. Yup, despite the title, Jay is gonna use Set Matte.

    That should get you going.

    Last bit - above I said you could use a color matte to define multiple areas of transparency? Here's a tutorial I did for FXhome as an example. I'll use a Comp Shot with text and a colored outline so I can use one matte layer to create two different matted areas for effects and color treatment.

  • DataDesign
    DataDesign Posts: 667 Enthusiast


    When I saw this question, I thought you were going to say something like make each layer into 3D and move the character layer in Z-space in front of the others. Then the character can just walk by. But is seems I may have, probably have a misconception of 3D layers maybe? What is the short answer? Thanks.

  • Triem23
    Triem23 Posts: 20,190 Power User

    @DataDesign That could work if there were multiple layers, but the original background being used is a clip from the TV show "Family Guy" where the OP is replacing a painting inside the original image. So, to separate things into 3D layers would be rotoscoping the ENTIRE body of Stewie. In this case it's just better to roto the head as a 2D layer.

    And, if Stewie (the baby character) was already isolated on a layer, then he could just be popped on top as a 2D layer, anyway.

  • 0xmethodic
    0xmethodic Posts: 4 Just Starting Out*
    Thanks all especially @Triem23 so much for your detailed explanation. I haven't tried your suggestion yet but am going to do so now for learning.

    I did manage to work it out myself last night. All I did was:

    1. Create 2 layers of the original clip
    2. Insert the painting in between the two so it was infront of the lower layer
    3. Mask the upper layer of Stewie's head and use keyframes "position" to move the mask across from the starting point to the final point (kinda like tracking his head, manually).

    It worked fine in the end and it seems a lot easier than your explanation. Is this method bad practice?

    As mentioned will still test out your method for my learning and report back.

    Thanks again!
  • 0xmethodic
    0xmethodic Posts: 4 Just Starting Out*
    So I've already gotten stuck :(

    Followed all of these steps:
    Stewie tracked successfully. Created white plane layer above clip and masked the plane to Stewies head.
    What do you mean by parent the plane layer to the tracked point? I tried parenting the plane layer to the original clip, as well as applied the tracking from the clip to the plane layer.

    Now after I played it, half the screen is white (looks like the whole plane layer went to the starting point of the tracking) and doesn't move when Stewie does. I also inverted it but if I do this the plane layer just goes black.

    Screenshot for reference.

    In the meantime I'll check out your tutorial. Surely I'm missing some very basic fundamentals and am getting ahead of myself here.
  • DataDesign
    DataDesign Posts: 667 Enthusiast


    Ahhhso! I thought (not always a good idea) that the character was already on separate layer because I scanned the post and assumed just from the picture. Who was it that said "Don't assume stuff."? :-)