Video editing with Blender

Publicado el domingo, 19 de febrero de 2012

This post is also available in: Spanish

 

This is a pre-publication of an article submitted to Blender Art Magazine

Blender has grown into an amazing tool, standing tall at version 2.62, and for those who did not have to unlearn the old interface, the new interface is much easier to get accustomed to than it was in the version prior to 2.5.

Although I have followed Blender and played with Blender for a number of years now, I have only now moved to the Blender Video Sequence Editor (VSE) for production. The reasons were twofold, one the one hand I got stuck in iMovie when I tried to sync my audio tracks precisely to the video. And on the other hand my main PC now runs Ubuntu Linux, and no longer OSX.

iMovie is amazing for doing a fast, no hassle edit of a video, and adding a recording an adding a soundtrack is just as easy. But it only goes so far. Blender on the other hand allows you to do almost anything you can think of, especially in combination with FFMPEG. But expect to be tearing out your hair at times figuring out how.

This is by no means intended as a manual, or even as a description of how to do things in Blender. Take it more as a long story about my experiences moving to this platform. The Blender manual itself is good, but you will need to rely on the chapters for version 2.5, which do apply but do not answer all the questions.

Setting up additional software for audio

The hardest part I found was managing audio. Although the Blender installer comes with FFMPEG built-in, it will not render always render the video with the audio that you have included.

The Blender Output and Encoding interface allows you to set all kinds of combinations of options that simply do not work, especially when you try to add an audio track. This only stops from being annoying when you simply separate the audio workflow from the video workflow completely.

The set of tools I ended up with are:

For Video

For Audio

If you are using Windows or OSX, the list would be shorter for audio: you can use Reaper now that it has the ability to add a video track.

Why so many programs? Well, what you give up in ease of use, you gain back in having control over every detailed aspect of the video creating process. To give some context of what I do, I will describe where the different components of a recent product presentation movie I made.

Video:

Audio:

Setting up and importing video

Make sure you set up the framerate of your video file in the Dimensions tab before you start working. For instance, if you are working with Nikon D90 you set the frames per second to 24 and the frame size to 1280 x 720. When you import your movie clips to the VSE it will set the frame rate according to these settings, not according to the video you are importing. So if you do not do it before you start, you would have to import all your scenes again.

Some video tracks I had converted earlier to the Apple intermediate codec, and I no longer had access to the AVI originals. These need to be exported using Apple Quicktime Pro, and using H.264 multipass encoding worked for me after some experimenting. In my case the audio of the video footage was never used, so I paid no attention to that.

Next I imported all the selected video tracks into blender, using separate channels for the video and the still images. The still images need to be on the higher number channels and have a transparent alpha channel. You can then set to “drop over” so that your video will appear below. Scaling down the images to 1280 x 720 works, however, I sometimes run into trouble with the de-interlacing settings. Just one odd pixel in your greys can lead to a white or off-colour pixel in the render in Blender. I have not figured out exactly how and why, but the ony solution I have found is to increase the amount of pixels (the resolution) of the images. If you do not have a higher resolution available, try removing (pretty much hit and miss) one of the lowest level transparent greys in Gimp. If you hit the right one, then suddenly many if not all of the white pixels in your render disappear.

Adding stills

There is a way to use Blender for moving titles and rolling credits, but I have not figured out yet how to do that. Instead I used a PowerPoint presentation as the basis for all the titles, subtitling, and credits, and edited these in GIMP. For the subtitles instead of using X exports from PowerPoint, I created one layer with the transparent subtitle pictures, and then X layers with the text. If you export from Gimp with the setting “export visible layers” you can quickly export each text as a separate frame. And it relieves you from going back and forth to PowerPoint and add the transparency to every single frame.

For adding the transparency, the option to substitute a colour (white in my case) for an alpha channel is great. For areas that where this is not wanted (a grey logo for instance), just use the selection tool in blender, and select the areas where white can be substituted safely before making the substitution.

Syncing audio

Either your soundtrack is ready and you only need to sync the video to it, or the soundtrack will need to be edited in iterations to fit your movie. The latter happens for instance when you are preparing a presentation with spoken text.

In either case, when you start syncing the audio to the video, make sure you have AV-Sync on. It will tell blender to always follow the audio dropping frames if it has to. One caveat: if you have included high resolution pictures stills, Blender is not able to drop the frames, and your sync to audio will be momentarily off. One way is to include a low resolution picture while editing and replacing it in your pictures folder with the high resolution version just before rendering. The other is to trust the time marker you set based on the audio wave-form and then check in the render if the timing is correct.

Next load the soundtrack that you have (I use Channel 0 as it is my reference for the placement of the rest) and make sure you set the option to Draw Waveform. If you have snippets of sound (like blocks of spoken tetx from your movie or presentation script), then you can add them one by one or drag them from the Blender File Browser.

You can do the same with the audio-snippets of your voice-over draft. When editing this way I put more empasis on getting the length more or less right based on these voice-over snippets. I then make a final version of the voice based on that, and a final edit of the video after importing the complete voiceover render (see below).

Rendering your Audio Track

You will need a DAW like Ardour on Ubuntu or Reaper on windows to make sure you can manage the fade-ins and fadeouts of music and voice if you use a soundtrack. What I did was to make a leader track of the voice with Ardour and and chop it up in snippets with Audacity (Audacity is great for quick and dirty edits like that). These snippets then went into the Blender VSE. With these leaders I could set the length of the videos and stills, and then decide on whether and how to redo the voiceover.

For the final edit, I moved the audio-less render of the movie to a file that can be read by xjadeo (or reaper if you work on Windows/OSX. You do not need a high quality version of the video, just enough to see all the frames, and make sure that you have enough processing power to edit the audio. One way is to reduce the weight of your render is to reduce the frame size by half, in this example export the 1080×720 movie to a 540×360 size.

All transport in Ubuntu is best handled by Jack, so you need to adjust Ardour accordingly and you do need to set the frame rate for the Ardour clock (under options -> FPS). My biggest challenge has been the fact that there are only 24 frames in a second. And that does not always allow for precise timing. There is no way around that in a long audio track, the 24 frames are fixed. However, voice-overs can be cut and readjusted more precisely.

After your final edits of the soundtrack, import it back again into your Blender project VSE. Make sure that you never change the start point of the audio track, or you will have to transpose all your frames to match the start. The end can be different, perhaps you have created a fade out where you want the movie to end. Select the new audio track and copy the length to the total length of your render.

This needs to be done, because to combine the audio and the video track in FFMPEG both the sound and the video file need to have the exact same length. There is an -shortest flag that tells FFMPEG to use the shortest of the two files as the length for the output. But then you lose the control that you went to all this length for on how the movie ends.

Rendering

Once all this is done, you will want to render the movie to a lossless format. It gives you a base-file that will serve as input for whatever file format you need the movie in (and these can be many – and once it is rendered you do not want to render it again). The more processors you have in your GPU the better. Even though for whatever reason Blender does not seem to make use of all the cores available, FFMPEG most definitely will at the lossless settings.

The settings for the current version of FFMPEG to

ffmpeg -analyzeduration 1000000000 -i ../AudioFiles/myFinalAudioRender.flac -i myFinalVideoRender.avi -ab 320k -ar 44100 -vcodec libx264 -preset veryslow -tune zerolatency -threads 0 myFinalMovieWithSound.avi

The key flag here is -tune zerolatency that will improve the quality of the audio syncing to your movie. Then it is a matter finding the FFMPEG to transcode the lossless version of your movie to the movie format you need.

Closing note

It took met the best part of two weeks to get adjusted to the new workflow. But I would not trade back for anything. The best part is the Blender interface, which allows you to define exaclty what you see on your screen. While editing I have a closeup of the wave form of my audio file in the left hand corner for instance, where the playhead (the green bar indicating what the current frame) will be visible across both the video sequences and the close-up of the audio.

I also realise that there is much, much to learn. In the above I have not even mentioned using compositing nodes to manipulate your video tracks. Or the possibilities to combine video with rendered animations. I do find that learning those aspects of Blender take time. As I said at the start, if it is a quick edit you want with nice out of the box features for adding text etc. do not bother with Blender, but stay with what you are comfortable with right now. But if you want to expand your tool-set in a creative and challenging environment, then by all means, Blender is the way to go.