Track Record
Tutorials – Natron
Natron allows you to create eye-catching effects and combine different video clips in surprising ways, letting you build up your clips like a pro.
In last month's issue [1], we had a look at Natron [2] and saw some basic things we could do with it. But Natron does much more than basic. In fact, doing complex effects and composites involving several tracks and techniques is what Natron does best.
To illustrate what you can achieve with Natron, read on for a couple of practical examples.
Transition
This effect lets you use an animation to transition from one clip to another. The animation in this case is a running person on a green background. The effect you want to achieve is having the character run from right to left, dragging the second clip in over the first one [3].
If you are a regular reader of Linux Magazine, this should be familiar to you. We did this effect using FFmpeg [4] and again using Kdenlive [5]. I'll quickly show you how to prepare the transition animation and then cut to the business of building the transition in Natron.
So, first things first, you'll need to get your animation ready. Step one is to split the animation clip into its individual frames:
ffmpeg -i runner.mp4 -ss 00:02:09 -t 00:00:07 runner_frame%04d.png
Broken down, this instruction is made up of the following components:
runner.mp4
is the video from which you are going to extract the frames.-ss 00:02:09
is the starting point of the sequence of frames you want to extract – in this case, two minutes and nine seconds into the clip.-t 00:00:07
is the length of the sequence in frames – in this case, seven seconds.runner_frame%04d.png
gives each frame a sequential name, likerunner_frame0000.png
,runner_frame0001.png
,runner_frame0002.png
,runner_frame0003.png
, etc.
Next you need to make the green background transparent and cut out the running man. The ImageMagick command
convert runner_frame0000.png -fuzz 40% -fill none -opaque "#13ff09" -trim alpha_cropped_runner_frame0000.png
will do both on your first frame, so that Listing 1 will do it on all the frames.
Listing 1
Transparency and Cut Out
for i in runner_frame0*.png;\ do convert $i -fuzz 40% -fill none -opaque "#13ff09" -trim alpha_cropped_${i};\ done
Get rid of (or move) the original clip and the original runner_frame*.png
frames, leaving only the cut out frames with transparent backgrounds in their own directory. Next, you can use the customtransitions.sh script you saw in [5] to finish off the preparation of the animation frames. To save time, you can download the script [6].
Figure 1 shows the desired result.
Natronizing
Time to fire up Natron.
A new blank Natron project contains only a Viewer node. The first thing you're going to do is right-click in an empty area in the Node Graph (lower left-hand pane) and go to Image. Pick a Read node. This will open a file explorer. Navigate to where you have saved your first clip in the transition sequence and pick that. The Read node will automatically connect to the viewer, as shown in Figure 2. The first frame from your clip will show up in the preview window.
Next bring in the animation frames you created with customtransitions.sh. To do that, create a new Read node and, when the file explorer appears, choose Sequence from the dialog's bottom left-hand corner. Navigate to where customtransitions.sh
stored your processed frames and choose the chroma###.png
series of frames.
If Natron connects the sequence to the Viewer, disconnect it by clicking and dragging on the arrow connecting the two nodes.
To composite the two inputs, clip 1 and your animation sequence, you need a Merge node, so right-click in the Node Graph and choose Merge | Merge from the pop-up menu. Select the new Merge node and, in its property box (column on the left of Natron's window), change the Operation value to color (selecting this option from the drop-down list).
Connect Merge's A arrow to your video clip and its B arrow to the animation sequence, as shown in Figure 3.
The preview pane will show something like what you see in Figure 4, which is a bit more than halfway through the transition.
It is time to bring in clip 2. In the same way as before, create a Read node and navigate to the where you have stored the second clip to which you want to transition. If Natron connects it to your tree of nodes, disconnect it and bring in a ChromaKeyer node by right-clicking in the Node Graph and choosing Keyer | ChromaKeyer from the menu.
Connect the output from your Merge node into the ChromaKeyer node and your clip 2 node to the ChromaKeyer's Bg arrow, as shown in Figure 5.
The final step is to tell the ChromaKeyer node what color to turn transparent. In the node's properties box, you can either adjust the Key color RGB values by hand, or, if you click in the color box (by default set to black), a little color picker will appear. Move it over to the preview pane, hold down Ctrl, and click on the green section of your animation clip. Presto! Clip 2 now shines through where before was garish green (Figure 6).
Time Offsetting
Your transition is all but done, but so far you have only seen how to apply it to the beginning of the first clip. As you are engineering a transition from clip 1 to clip 2, this is not what you would usually want to do. On the contrary, what you really want to do is place the animation at the end of clip 1. You also want to push the beginning of clip 2 towards the end of clip 1, to when the transition starts.
Although this is bordering on video-editing territory (which is not Natron's purpose), in this case at least, it is legitimate thing to do. To move the beginning of an effect or a clip along the timeline, you can use a TimeOffset node (right-click, and then Time | TimeOffset). Hook it up as shown in Figure 7 and, in the TimeOffset node's property box, change the Time Offset (Frames) value to, say, 100 to make the animation transition start on frame 100 of the overall project.
You can now select and right-click on the TimeOffset node and clone the node by choosing Edit | Clone Nodes from the pop-up menu. Use the cloned node (a pinkish red in Figure 7) to delay the start of clip 2 as well, so it coincides with the beginning of the animation. By cloning the node (instead of just creating a new one), you can guarantee that both clips will start at the same point in the project.
Although we have made sure all our clips are the same size for this experiment, you can also resize a clip on the fly with the Resize node (right-click, and then Transform | Resize). However, if you dragged in a large clip, the view port may still show a great big empty area (the size of the biggest clip) even after you have resized it. This is normal: Natron by default resizes your project to the size of your largest clip's frame. To fix this, you need to readjust the project's settings. Mouse over an empty space within the node working area and press the S key on your keyboard. The project settings will show up in the Properties column on the right. Change the size of the project in the Output Format field.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.