When we work in editionit is Of video complex it is common that we need to perform video composition tasks, adding titles, superimposing trimmed clips, etc. And this is when it is useful to be able to export video clips with transparent backgrounds, both in video format and in image sequences. Thus we reduce the burden of our project. Because in a clip that we have many effects, if we export this one, we have the same result, but without effects, so in this way we save resources.
Export with transparent background in Cinelerra
In the previous tutorial, which talked about the insertion of Titles or Texts, we saw a practical example of text animation.
Let’s imagine that this composition, which I made in the previous tutorial, is the heading of a series of chapters, and it will always be the same, but these texts will go in each chapter with a different video background. This would be one of the many situations where it is very useful to have this clip with transparent background.
To have it with transparency, we must use one of the options that Cinelerra offers us for this purpose. These different options range from a video clip with a transparent background, or a sequence of images.
Export a video clip with transparent background
After trying several options, of which they can be used in Cinelerra, I am going to recommend the one that I liked the most because of its quality-to-size ratio.
This has been the one of use mkv container with codec ffv1.mkv and yuva420p pixel color mode.
The less we compress the color, the better quality we get, but at a larger file size. We can use the yuva422p color space if we want a better quality, (yuva444p is the one that least compresses the color and gives us the best quality). For this example, as I simply export some white texts, I am going to use the 420 color space but in color images I usually use 422 or 444. To learn more about the color space in video compression we can consult this web. And to go deeper into this topic this web it can be very useful. This type of compression is called “Subsampling“, in Spanish “subsampling“. For those of you who are more than videos, this guy dubbed into Spanish a excellent video explaining this.
Let’s see how we do this:
We open the render assistant to export the clip we need with a transparent background and look for the Matroska video extension, that is, the .mkv extension, then we open the video codec settings and adjust the Compression in ffv1.mkv and the Pixels in yuva420p
As I have mentioned before, there are other options, but the important thing to export with transparencies is that the codec supports alpha channel. This we know if this is the case, in the color space to be exported, here called pixels, it must have an “a”, which indicates “alpha channel”
Codecs that support alpha can come in various forms, depending on the color space used, and these can be:
- yuva (yuv color space with alpha channel)
- bgra (rgb color space with alpha channel)
There are a few more options. And some codecs that despite following this nomenclature do not really export with transparency.
In the following image we see some tests that I have carried out with the text clip that we saw as a practice in the previous tutorial. That is 5 seconds and with only text. And look at the sizes.
All these videos are exported with the FFMPEG specification, the name starts with the chosen format option, then the compression and pixels.
In a clip with only white text of 1920 × 1080 at 25 frames, of 5 seconds in length, we go from 5.3MB to 1.0GB… of vertigo this last figure for only 5 seconds.
The reason why I have recommended mkv with ffv1.mkv and the Pixels in yuva420p is because of the good quality-to-size ratio, and because it works well in color clips, and because it is the format that video portals on the network usually use. But in exports, with transparent cuts, sometimes you have to try different options until you get the best result. In Cinelerra there are more options for transparencies, but the mkv or qt options are good options and with them we get a good quality-to-size ratio.
For example, in the previous image of export examples, we see that the one that gives us the smallest size is that of qt with rle.qt argb, but with color images this codec will create files 10 times larger than the recommended mkv. View the following sizes with a 5 second long colored clip that I have drilled a hole in the center.
But if the most optimal seems to be already 8?
ffv1.mkv with ya8 pixels is very useful only for black and white clips. If we export a color clip with this codec we will obtain a result in grayscale or black and white.
Export a sequence of images with a transparent background
The process is identical to the one seen to export video, only that we must use an image format that supports transparency and choose the appropriate codec. I’m going to use the FFMPEG format specification with the png image type that supports alpha channel.
The first and important step is to choose Pixels in “rgba” so that it is exported with a transparent background.
But what is important is to put the code in the name so that the frames are numbered sequentially. We achieve this by putting the following in some section of the name,% 05d. Even the name can be just this indicator (thus being% 05d.png). It is highly recommended to create a folder to host each image sequence.
The result is a sequence of images ordered by number. For example, if we have used% 05d.png as the name, the files will be named as 00001.png, 00002.png, etc … if you had used this name, for example, secAlpha_% 05.png, the result would be, secAlpha_00001.png, secAlpha_00002 .png, etc …
Whatever the name used, it must include this command,% 05d, if it does not contain it, the sequence of images will not be performed. In fact we see that in the wizard, to choose the type of compression, there is a help that emphasizes the name.
At the end of the render, we see that next to the images, a file has been created, with the name that we have given to the sequence. Instead of being numbered, it has the code% 05d.
This file is very important, since it is the file that we will use to load the sequence of images in Cinelerra.
This file works exactly like a video clip.
Another technique for exporting an image sequence
We can use another alternative to export a sequence of images. This is to directly choose the preferred image type in Format. The only condition is that if we want transparency, the format must support it. For example choose “PNG Sequence”. In this situation it is not necessary to put anything special in the name. But look at the extension! which in this case is not .png, but .pngs. The extension ends in a sequence “s”. It is important to activate the option “Use Alpha” in the video settings to obtain the transparent background. I have set the compression to maximum to reduce the size of the export. In a sequence with only white text an 8-bit depth is more than enough.
A file is also created, as in the previous option, which is the one that we will use to load the sequence of images as if it were a video clip. This file will be named with the extension .pngs. In both cases, this file must be inside the folder that contains the images.
Upload Image Sequences to Cinelerra
We have just seen that when we export a sequence of images, whatever the two views, Cinelerra creates a text file for us, either with the same extension used for the images, or this plus an “s”. For example, for the png image type it would be like this, .png or .pngs, and as we have seen these files help us to load this sequence of images as if it were a video clip. I emphasize that these files have to be in the same folder as the images.
But what happens If we have done this sequence with another application, such as Blender or Natron, for example?
These applications do not create the file for us to load the sequence in Cinelerra. But we can create it in a very simple way.
There are also two ways to do this and they both work perfectly, I’ll explain the easy one first. This simply consists of looking at the name of the files of the sequence of images that we want to load as if it were a video clip in Cinelerra.
It’s very important the images in the sequence are in the same folder.
For example, let’s say we have a sequence of images with the following name:
So what we should do is open our favorite plain text editor, gedit in ubuntu, xed in Mint, kate in KDE … etc. Write something, a word, a period, whatever, that the file is not empty, this is the only content condition of the file. The one that creates Cinelerra by default puts content, IMAGE2. And we save it in the same folder where we have the sequence of images with the same name and we substitute the sequential numeric code for% 03d
And that’s it, when we load this text file, Cinelerra will open the sequence of images from it as a video clip.
If these files have the following name:
The text file will have to be named as:
Why before% 03 and now% 04?
This number indicates the number of numeric digits in the sequence.
For example if we have a sequence with this name:
The text file will have to be called:
The only thing that must always be put is the symbol% after the number of digits with two figures and to close this command the letter d. So this is% 05d in the place of the sequence number in the image files. Where, as we have seen, the only thing that can vary is the number of digits. 05 indicates 5 digits.
For example in a sequence the name is:
The file to load this sequence should be called:
This is valid with any type of images, the only thing is that you have to put the corresponding extension.
In this simple way we create the file for load the image sequence as a video clip in Cinelerra.
With the option that we have just seen, the text file has to be in the same folder as the images, with what is indicated for the name, and with at least one content character. If not, it doesn’t work.
This time it is about creating a file that ends with the extension plus an “s” of sequence. And very important, the sequence of images in a single folder and preferably that there are no other types of files.
To do this we simply open a plain text editor, the one of our preference, and we must put the following content, the example is for .png images.
PNGLIST # Fotogramas por segundo 25.00 # Ancho: 1920 # Alto: 1080 # A continuación el listado de las imágenes ./PruebaSec000000.png ./PruebaSec000001.png ./PruebaSec000002.png ./PruebaSec000003.png ./etc...
We see that we have to indicate the type of list
- For png PNGLIST
- For jpg JPEGLIST
The frames we want this sequence to work on.
The width and the height.
And finally the list of images.
Make the list of images quickly
There is a very useful trick to make the list of images, and it is the following, we select all the images in the sequence, copy them, go to the text file and paste, this will paste the path of the images plus their name. As follows, for example:
/ home / username / folder path / image name 0001.png
/ home / username / folder path / image name 0002.png
/ home / username / folder path / image name 0003.png
This would be an absolute path, now with the text editor assistant, Find and Replace we do the following:
We select the path, minus the name of the images, and replace this with ./, which gives like this:
./ image name 0001.png
./ image name 0002.png
./ image name 0003.png
and we already have a relative path.
Now we save this file in the same folder of the images, with the name we want with the extension of the images plus an “s”. Here the name is indifferent, the only important thing is the correct extension ending with an “s”.
Using absolute paths the text file does not need to be in the same folder as the images. But if for whatever reason we change this site folder, or its name, the sequence will stop working.
Using relative paths the only condition is that the file is in the same folder as the images.
Next we see a capture of the xed editor of how an image sequence file in png format would look.
Advantage of this mode
The only advantage that I see, of making the sequence file of this type, is that we can modify its speed by varying the value of frames per second.
For example, if to a sequence that is exported at 25 frames per second, we change this value to a lower one, the sequence will go slower, if it is higher, faster. For example, if in this case I put 12.5 here it will go at half speed and it will last twice as long, if I put 50, it will go twice as fast and will last half.
I thought that changing the width and height values would change the size of the clip, but it hasn’t. But it is necessary to set these values for Cinelerra to load the file. I have even set the value 1 both in height and width, and it has worked for me the same as with the real values of the image.
Simplify the file
We can simplify this file by removing the comments, and it would look like this, the comments are the lines that start with a hash mark, #.
I think that after this tutorial we should already know work with image sequences in Cinelerra