kdenlive — Video Editing on Linux

A collection of video editing tips for kdenlive which will help improve your videos. There are some fun ideas for special effects you can include in your video projects.


Index


Syncing audio & video

What makes a really good video isn’t always the quality of your video footage but the quality of your audio. Especially if you’re talking to the camera you need to be able to hear the audio clearly. This usually means recording the audio separately from the video using a high quality microphone. When you come to edit your video you need to sync up the audio file with the video footage.

In this sample video I recorded the audio using my mobile phone and a lavalier lapel microphone. You can probably just make it out attached to my seat belt. The video was shot using a QUMOX SJ4000 sports camera attached to the windscreen using a car mount.

When I filmed this, I started the camera rolling and fixed it into the car mount. Then I started the audio recording on my mobile phone. The difference in the starting points was around 30 secs. You can see from the kdenlive screen shot below that the audio track starts much later than the video track. So how do you sync up the audio from your audio device to the audio from your camera?.

kdenlive audio sync

Some people recommend clapping and then using the audio spikes in the timeline to line up the two tracks. This is very imprecise and if not done correctly you will notice a lip sync issue if the audio is slightly out from the video.

kdenlive has a nifty built in function to do this accurately without any clapping nonsense. Start by right mouse clicking on the video track and selecting the Set Audio Reference menu option from the pop-up menu. kdenlive will then process the audio which was captured from the camera. This may take a while if it’s a long video clip.

Once the processing has finished right mouse click on the audio track and select the menu option Align Audio Reference. The audio track will then be analysed against the reference audio and moved along the timeline to the correct position to sync the two tracks.

Once the two tracks are synced it’s a good idea to lock them together by grouping them. Select both tracks within the timeline and use the keyboard shortcut Ctrl+G to group them together. You should also mute the audio on the video track as you’ll be using the higher quality audio recorded on the dedicated audio device.


Rotoscoping #1 - Highlight one person in full colour while keeping the rest of the video in black & white

While editing our family skiing holiday video I wanted to try and recreate the technique used in the film Schindler’s List — the one where the whole film is in black & white while one character within the video stands out in full colour. My youngest son wore a red ski suit and I thought this would be a perfect opportunity to try out this technique. It turned out to be quite easy using my preferred video editing software kdenlive. It just takes a little bit of patience to mask out the person you want to remain in colour.

Here is a short clip demonstrating the finished effect & below I go through the steps necessary to create this within your own video projects.

You need to capture the raw footage in full colour. Determine which section or sections of the video you want to apply this technique to and trim the excess footage. Once you have your selected clip on the timeline you need to make a copy of it and place the copy on a separate track directly below the first. The lower clip will have a black and white effect applied to it. The top clip will be used to mask out the selected person in colour.

kdenlive timeline

To apply a black and white filter effect select the lower track in the timeline and press your right mouse button to get the pop-up menu. From the menu choose Add Effect/Colour/Greyscale

kdenlive effects menu

The next step is to apply a composite transition between the two tracks. Select the upper track and again press your right mouse button to invoke the pop-up menu. Select Add Transition/Composite. A yellowish rectangle will appear spanning the two tracks showing the extent of the composite transition. The rectangle may not extend for the whole length of the clip. Using your mouse grab the right hand edge of the composite rectangle and stretch it out to cover the full length of the video clip.

kdenlive stretching the composite layer

It is also worth checking that the composite transition has picked up the correct target track. In this example it would be track two. You can check this using the Transitions tab. The option will show Type Composite with track and the selected track will be highlighted. You can choose a different track by selecting the correct one from the drop down list.

kdenlive transitions tab

At this point if you play the video the whole scene should be in black and white. We now need to use the rotoscoping tool on the upper video track, which contains all the colour information, to mask out our chosen character.

Rotoscoping

Rotoscoping has often been used as a tool for visual effects in live-action movies. By tracing an object, a silhouette (called a matte) is created that can be used to extract that object from a scene for use on a different background. In our case we are going to extract the skier in the red jacket and apply them to the track which has been made black and white.

Select the upper of the two tracks and add the rotoscoping effect by selecting the menu options Add Effect/Alpha manipulation/Rotoscoping. You then need to go to the first frame of the video clip which can be achieved by pressing the Home key on your keyboard. Within the Project Monitor window you need to draw an initial mask around the character or person you want to highlight in colour. The mask outline will be shown in a yellow line.

kdenlive rotoscoping mask

The next step involves patience, especially if your character moves around a lot within the frame. You need to scroll through the video clip frame by frame by pressing the right arrow key on your keyboard. When any part of your character moves outside of the mask outline, you need to create a new key frame.

A key frame is a frame used to indicate the beginning or end of a change made to the signal. For example, a key frame could be set to indicate the point at which audio will have faded up or down to a certain level. In our case the key frame is used to instruct the rotoscoping effect that the mask boundary needs to change shape or position.

Using the Effects Stack tab you can create a new key frame by selecting the Add key frame button shown below. Once you have created the key frame, you then need to move the points on the mask within the Project Monitor window so that the character is again within the mask boundaries. Try to ensure that you don’t accidentally include other people within the mask area. The more time and care that you can spend on this step the better the finished results will be.

kdenlive rotoscoping effects tab

Keep repeating the process of stepping through the video, inserting keyframes and adjusting the mask area for the full length of your clip.

If you apply other effects to the black and white track you will also need to apply the same values to the colour track or the rotoscoping effect won’t work properly. For instance, I added a Brightness effect to lighten the contrast within the black and white video as the original footage was too dark having been filmed in a forest. By applying the same brightness settings to the colour track I was able to remove the strange ghosting effect that appeared due to the mismatch.


Rotoscoping #2 - Jumping through solid objects

This was a fun project I worked on with my eldest son. The visual effect is jumping through a solid object with the clothes being left behind as the person disappears through the wall.

The key to creating this effect is to fix the camera on a tripod and not move it through out the filming. Start by filming the scene for a minute with no movement at all. This will be your base footage used for rotoscoping yourself out of the shot as you drop the clothes.

If you look at the screen shot below the video on track 2 is this base footage. The video on track one is of me holding the clothes & dropping them. You need to add a composite transition between the two tracks. Add the rotoscoping effect to the top track by right mouse clicking on the track and selecting the menu options Add Effect/Alpha manipulation/Rotoscoping.

kdenlive rotoscoping

Make sure the rotoscoping mode is set to Alpha and the Alpha operation is set to Write on clear. Within the Project Monitor window you need to draw a mask around the area were the clothes will drop, making sure not to include yourself. This will then remove you from the shot by displaying the base footage from the second track for the area outside of your mask.

I actually pegged the trousers & top together on the inside, so that I could hold both from the top and drop them both easily at the same time.

holding pants before dropping

As you can see from the above photo the original video was shot in colour. However, the lighting changed during the shooting as the sun came in through the window. A change in lighting can ruin this effect so it’s best to do it on an overcast day when lighting levels are less likely to change. Or you can do what I did here by converting it all to black & white.

I thought it would be fun to reverse the video, so that the clothes jump up from the floor and person comes backwards out the wall. It’s quite easy to reverse a video file from the Linux command line.


Extract a single video frame & save as an image

The main reason I video family events is to ensure I capture every facial expression. There is no way I could have captured my sons facial expression while riding this sledge ride if I’d just used a traditional stills camera. So if you video everything and capture a great moment, it’s easy to save a given frame as an image file.

extracting a single video frame

With the video loaded into kdenlive, you can use your and keyboard keys to step through the video frame by frame until you capture the perfect image. If you then right mouse click in the Project Monitor window you’ll get a pop up menu. Select the Extract frame option and you’ll be prompted to save the image to a file on your computer.


The render profiles I use to create HTML5 videos

Rendering your video project is the process of applying all your special effects and producing a finished file that can be uploaded to YouTube. All the video samples on this page use the HTML5 video player instead of YouTube. By using HTML5, I have to render the project three times to create the following file formats mp4, ogg and webm

The rendering dialog box shown below can be opened by selecting either the Render option from the toolbar or by using the keyboard shortcut of CTRL + RETURN

Change the destination drop down list to “File rendering” which will load a selection of profiles to choose from. You could use the MPEG-4 option to create the mp4 file, but for some reason the produced video file won’t play on Android tablets or phones. So I use the H.264 option and give the final file a .mp4 extension.

rendering a finished video

I set the video bitrate to a value of 2000 with the audio set to 384.

I also ensure the “2 pass” tick box is ticked. This will make the rendering process twice as long, but the resulting movie file is much smoother. Try it out for yourself and compare the differences between a single pass against a rendered file which has had two passes.

I then repeat the render process using the Theora profile for the ogg file and the WebM profile to create the webm file.

Once I have the three file formats rendered I upload them to Amazon’s Cloudfront content delivery network. Using Cloudfront ensures the video files are served up from a server near to the user watching the video. Which makes them load much faster. Don’t try hosting the video files yourself. If your video becomes moderately popular your web server wouldn’t be able to cope with the load.

After the files have been uploaded to Cloudfront, I then include them onto the web page using the following HTML code.

<video poster="cover.jpg" controls="controls" preload="none" width="640" height="360">

 <source src="https://nhs.cloudfront.net/render.webm" type="video/webm">
 <source src="https://nhs.cloudfront.net/render.mp4"  type="video/mp4">
 <source src="https://nhs.cloudfront.net/render.ogv"  type="video/ogg">
</video>

Web browsers will tend to read the list of source files until it finds a format that it understands and can play. So I list the source files so that the smallest files are first in the list. As the webm codec seems to produce the smallest video files, it’s usually fist in the list.

To create the cover jpg file used within the poster attribute I use the extract frame method shown above.

↑ Top