Adding a spotlight effect to a video using Blender
Recently I needed to add a spotlight effect to a video to highlight and follow a particular object in the scene. Blender is a fantastic piece of software which comes with a built-in video sequence editor. Fiddling around in Blender, I managed to come up with a solution which works quite well. I'm not sure if it's the best way to accomplish this so if you're aware of a better method please let me know.
Blender - Blender is a free and open-source 3D computer graphics software which includes a video sequence editor. It's cross-platform so no matter what desktop operating system you are running you should be able to use it.
A video file to which you want to add a spotlight effect.
The desired result¶
For the purposes of demonstrating this effect I used a short clip from the 1935 Looney Tunes animated film Hollywood Capers, where Beans the Cat sneaks into a Hollywood studio disguised as Oliver Hardy. The video below shows the result.
Setting up blender¶
The first thing we need to do is set up Blender for video editing.
Open Blender and select the
Video Editingitem on the splash screen.
The default workspace for video editing will be displayed, as shown below.
There are five areas in the default video editing view:
- File Browser
- Video Sequencer - Preview
- Video Sequencer - Sequencer
Loading the video¶
In the File Browser, navigate to the video you want to edit and then drag it onto the Sequencer area. If your video has sound, two strips will be displayed in the Sequencer area, a blue strip for the video and an aqua strip for the audio.
In the Sequencer area in the image above, you can see a thin, vertical black line just after the eight second mark. This line represents the end of the playback range, which in my case is roughly in the middle of the video. If we were to play the video, it would restart after eight seconds, never reaching the end. The playback range can be adjusted by setting the
Endfields, located at the far right of the Timeline area. In this example, setting the
Endframe to 411 aligns the playback range with the length of the video.
We will use the Movie Clip Editor to draw the spotlight effect. As we no longer require the File Browser we can load the Movie Clip Editor in its place. Each area in Blender can display any of the available editors. As shown in the image below, click the
Editor Typebutton (always the left most button in the header of an editor) and choose Movie Clip Editor.
Blender will now look like the following:
Before going any further, let's reset the playhead to the beginning of the video. This can be done by dragging the playhead back to the first frame or by using the shortcut
Now click the
Openbutton in the header of the Movie Clip Editor and select the same video file you opened in step 1.
Drawing the spotlight¶
We can achieve the spotlight effect by adding a mask in the Movie Clip Editor. Then, in each frame of the video, we can ensure the mask is positioned over the object that we want in the spotlight. The following steps illustrate how to do this.
Change the editing context from Tracking to Mask, either by selecting
Maskfrom the Editing Mode menu (shown below) or by pressing the
Once in Mask mode, click the
Addmenu in the header of the Movie Clip Editor and select
A circle shape will then appear in the lower left corner of the clip.
To position the mask over the subject, press the
Gkey to activate the Move transformation mode and then move your mouse. The mask will move with the mouse. Left click the mouse to exit the Move transformation mode. If you accidentally deselect the mask you can select it again by pressing the
Akey, which is the shortcut for Select All.
The mask is now positioned correctly but it needs to be a little bigger. With the circle shape selected (press the
Akey if it isn't) press the
Skey, which is the shortcut for Scale transformation mode. When in the Scale transformation mode, moving your mouse away from the centre of the selected object will increase its size and moving your mouse towards the centre of the selected object will decrease its size. Once the circle covers the subject, left click the mouse to exit the Scale transformation mode.
Now that the mask in place, click the
Auto Keyingbutton, which is the record button in the centre of the Timeline header. With Auto Keyframe enabled, Blender will automatically insert keyframes for objects.
Now we just need to move through the video frame by frame and move and scale the mask so it always encircles the subject. You can move backward and forward one frame at a time by pressing the
Right Arrowkeys respectively.
Note: It's not necessary to adjust the position and size of the mask in every frame. If the subject is moving in a straight line, as is Beans for the first 106 frames, you can jump to the frame before the subject changes direction or stops moving and position and size the mask accordingly.
The following video shows an example of the mask moving with the subject.
Once you have finished tracking the subject with the mask, the next step is to apply the mask to the video in the Video Sequencer.
Adding the mask to the Video Sequencer¶
At the moment, the mask is only in the Movie Clip Editor. In this section we'll add the mask to the video that we have loaded in the Video Sequencer.
In the Sequencer area, select the video strip (the blue coloured strip) by clicking it with the left mouse button and then make a duplicate either by right clicking the strip and selecting Duplicate or pressing the
Dshortcut. The copy of the strip will move with your mouse. Place the strip in an empty channel by left clicking the mouse. The image below shows the duplicate video strip in channel number three.
With the original video strip selected, open the Modifiers panel (the highlighted area in the image below).
Add Strip Modifierdrop down list in this panel and select
In the mask modifier that appears, select the
Click in the Mask field and select
F Mask. This is the mask that we created in the Movie Clip Editor. The modifier panel should now look like the following:
We have now added the mask to the video in the sequencer; however, it's currently hidden by the duplicate video strip in channel three. In the next section we'll blend these two strips together so Beans is in the spotlight.
Revealing the mask¶
Select the duplicate video strip in channel three.
Then, open the Strip panel, which is located in the Sequencer's properties pane, just above the Modifiers panel.
We now need to adjust the
Opacityslider which is located under
Adjust > Compositing, changing the opacity to somewhere around 0.5. Feel free to play with this value to get the desired contrast between the spotlit area and the rest of the video. The image below shows the adjusted opacity.
Play the video, either by clicking the
Playbutton, located in the centre of the Timeline header, or by pressing the
Spaceshortcut key. In the Video Sequencer Preview area you should now see the spotlight following the subject.
Rendering the video¶
Now that we have create the spotlight effect we just need to render the final video.
Open the Properties editor and set the
Outputfield to the directory where the final video should be saved and the
File Formatfield to FFmpeg video.
In Blender's Topbar menu click
Render Animation. The render window will appear and can be closed once the rendering is complete. You will now have a video file in the directory you specified in step 1.
As you can see, it's quite straightforward to add a spotlight effect to a video using Blender. I haven't explored other ways to accomplish this so if you're aware of a better way please let me know.