Tuesday, June 22, 2010

Time Lapse, First Attempt


This was my first attempt at creating a time lapse video, using the beautiful Hood Canal on a very foggy day. I made a lot of mistakes, and learned quite a bit- and though there is a tremendous amount of room for improvement, all things considered I'm fairly happy with the final product.

I'm going to document my entire process as a set of tutorials, because I believe there is value in everything I did, even if was not really the best way to do it. That's how I look at it, anyway- it was all a very educational experience. However, keep in mind that if you take note of what went right and wrong in what I did, you likely will not have to use all of these steps in your own time lapse video.

Postmortem

What went right

  • Choice of tripod and camera seemed to work well.
  • Indoor approach worked well during the day.
  • The weather worked out well.
  • Good subject matter.

What went wrong

  • Wrong camera mode.
  • Moved camera several times during process.
  • Indoor approach caused reflections at night.
Ultimately, my biggest mistake was not understanding my tools. Unfortunately, my little point-and-shoot Casio does not have an intervalometer feature, so I had to use my wife's beefier Canon, with which I am not as familiar.

Because of this, I didn't set up the camera properly. I chose a camera mode that automatically adjusts the shutter speed and aperture values on each shot, and I did not put the camera in manual focus mode, either. This caused a lot of issues with some frames being blurry, and others having different depth of field. The end result is a lot of jitteriness that is very difficult to account for in post.

Another mistake I made was one of practicality. It's very rainy where I live, so to take a time lapse like this I decided to keep the camera indoors, pointed through a very clean window. This worked fine during the day, but as night approaches you can see lights flicker on and off in the reflection of the window.

Finally, since I was really just testing this out, I moved the camera around several times during the process. At one point, I actually took it off of its tripod to go download the photos, making a short test video. This, naturally, caused some issues that were fun to try to fix in post.

Next Time

  • Shoot through an open window.
  • Do not interrupt the process.
  • Put camera in full manual mode.
  • Manually set camera focus.
  • Possibly adjust shutter speed as night approaches?
Set Up
Preparing for a time-lapse is fairly straightforward:
  • Choose a camera. You'll need an intervalometer (built-in or otherwise), as well as full manual mode and manual focus.
  • Use a tripod, or some other flat surface. Make sure the camera will move as little as possible. 
Once you've got your gear ready, it's time to frame your shot:
  • Find some dynamic subject matter that won't move much.
  • Configure the right aperture, exposure, white balance, and ISO settings. 
  • Make sure nothing on the camera is set to automatic.
  • Put the camera in manual focus mode, bring subject into focus.
  • Take a few test shots.
  • Configure your intervalometer.
Your subject matter will determine how long your time lapse is going to take. I chose a skyline with clouds for my first attempt, because this is something I can tackle in a single day and get some interesting results. Clearly, if you're going to do something like capture a flower growing, the time span is going to be different. I suggest, for your first attempt, pick something you can do in a day.

Once you know what you want, set up your intervalometer. Mine, unfortunately, is only able to take 100 photos max at a time, at a minimum of 1-minute increments and a maximum of 60 minutes. Ideally, you would have more control over your settings- a timer up to 24-hours and unlimited number of shots (memory permitting) would be great.

If your test shots look good, start the process and... wait.

Post Production
The steps you'll take in post production depend on the results you get. Depending on how well your shoot went, you may or may not need to do some of the following:
  • Stabilize the footage.
  • Combine / align multiple takes.
  • Adjust color balance or other levels.
  • Slow down or speed up the timing.
In the simplest case, you stitch your photos together, output a movie and that's that. Pick and choose from the following steps to do what's right for your results.

Create Image Sequence
The first thing you'll want to do is make a movie from a set of photos. This is the only step that is absolutely necessary when making a time lapse.

I'm going to go over two separate methods, involving different software. Both of which, unfortunately, cost money- though Quicktime Pro is relatively cheap. After Effects, not so much. If you happen to have both, it's worth doing the QT method first as a quick preview.

Create an Image Sequence in Quicktime Pro
Quicktime Pro can easily import a series of images into a movie. Use the "Open Image Sequence" option under the "File" menu to open a series of images.
Select only the first image in your sequence. Make sure all of your images are in a single folder, and that they are numbered sequentially.
A dialog will pop up asking you to choose a frame rate. Choose a good balance between video length and smoothness. Between 10 and 30 FPS is usually good.
With the frames imported, you can try to preview- but you'll notice the video is very large, and depending on your system performance it may not play smoothly.

To see the video properly, you'll want to export it. Select "Export" from the "File" menu.
Select "Movie to Quicktime Movie" as the "Export" type. Don't fret too much about this, recall that Quicktime is just a container format.
Click the "Options" button to bring up the options dialog.
The "Settings" menu contains framerate and compression type options.

The "Filter" menu contains various effects, including a color balancing filter that might be handy if your pictures are not all uniform.
For now, click the "Size" button. Since your video is based on photographs, and not video frames, chances are the video is much larger than you would like.
Choose your own dimensions, or select one of the presets. You should have no problem generating 1080p output, if that's what you want.

Chances are also good that your photos are not the right aspect ratio. Check the box to preserve the ratio, and select letterbox or crop.

I prefer a crop, but if you've got something important near the edges of your subject, you might want to letterbox. There is another option "fit within dimensions"- from what I understand, this will change the output resolution so that your movie will fit properly. Not really what we want in this case, unless you're okay with a non-standard aspect ratio in our output video.

Finally, click "Ok" on any settings dialogs, and click "Save" to export your movie.
Create an Image Sequence in After Effects
Start a new composition. You'll be using this composition as your output, so set up the resolution and frame rate to be how you'd like the end movie. I chose to use the 1080p preset, but it's really up to you. Just be sure to use "square pixels". To create an image sequence, drag a folder full of photos onto the project panel. Do not use the "Import Multiple Items" command, as this will import each photo as a separate image instead of creating a sequence. I separated my photos into a few sets based on gaps in the time lapse where the camera had moved. If you have more than one set of photos, import one folder at a time. You can rename footage to something more descriptive by right-cliking on a sequence and selecting "Rename". I named my footage "Take 1" through "Take 5". Create a new composition to hold the image sequences. This composition is going to hold the photos and provide a sort of "window" for the output. I defined the dimensions of my Images composition to be larger than each photo's size, to give me room to align and compose the different takes. Double-click "Images" in the Project panel to open the new composition. Highlight all of your image sequences, and drag them into the timeline to add them to the composition.

You could also drag them into the viewport, letting you position them at the same time. After Effects will line up all of the clips at the zero time marker. This might make sense in some cases, but I want the clips to follow each other sequentially. You may need to zoom in to make sure there is no overlap or any empty frames. Once aligned, your clips should have a "stair step" look. Now, you'll want to figure out how long your total video is. The easiest way to do this is to simply srub to the end of the video, and then look at the time marker. Select the "Output" compostion and open up the properties window. Set the length of the composition to the total length of all of your clips.

At this point, you can go ahead and render your composition.
Align Footage
If you've got multiple takes, each one possibly with different framing or even zoom, you're going to want to line them up so that there isn't as much of a jarring transition between them. You could simply import all of your images in a single set, and use motion stabilization, a topic we'll cover in the next section.

However, if you only have a few takes it may be simpler to line them up by hand. Grab a corner of the blue frame around your selected layer to resize it. Be sure to hold shift while you drag- this will maintain the aspect ratio of the clip. Click and drag inside of the blue frame to move the selected layer. Select the next layer, and so on.

Drag the timeline slider back and forth across the transitions between your layers. This will help you visualize the difference between the two and line them up properly.

You can switch the view to wireframe to get a good view of how your layers line up to one another.
Stabilize Motion
After Effects has some powerful motion stabilization tools based on a flexible tracker interface. The system is actually pretty easy to use, and can produce great results, if used well. If used poorly, however, it can actually add a lot of jitter and jumps to your footage- something you may have to tweak by hand after the autmoated process is finished.
To use motion stabilization, right-click on a layer in the timeline and select the "Stabilize Motion" menu item. This will add a new tracker to your layer, and activate the "Tracker" panel. A tracker is a complex object consisting of a few pieces- each of which can be difficult to grasp (pun intended! They're hard to grab...)

Adobe does an excellent job illustrating a tracker, so I'm going to steal the diagram straight off of their reference page for motion tracking. (I hope they don't mind!)

A.Search region
B.Feature region
C.Attach point
The search region is the outermost box of the tracker. This defines the area that After Effects will search each frame for the feature you are tracking. You'll want to click and drag on this box to expand it a bit, large enough to cover however far your footage might jump in a single frame. Keep in mind that making the search region large will greatly increase the processing time required to analyze your footage! Click and drag inside of the tracker to move it. While moving, the tracker will show you a magnified view of the search region. Try to pick a high-contrast area, and (most importantly) an object or feature that will be in frame as long as possible, preferably the entire clip. (Otherwise, you will need to stop and re-start the analyization in the middle, after re-framing the tracker). The feature region defines the area that After Effects will be looking for in each frame of your footage. It's the object or feature that you want to track. Click and drag this inner box until it covers a high-contrast area, preferably an entire object or feature. Once you're happy with your tracker, click the "Analyze Forward" button. That's the small "play"-like triangle button over on the "Tracker" panel. Depending on the size of your tracker, this may take some time- you should be able to watch its progress. After analyzation, your tracker might look something like this (if you've got some jumpy footage). Each little blue square represents a position the tracker moved to during analyzation. You can scrub through the timeline and see the various keyframes for each tracker point. Double check to make sure it looks right, and delete any spurious key frames, if necessary. Note that, by default, tracking will only occur for position. This means After Effects will only shift your image horizontally or vertically- it will not scale or rotate your image. If your camera moved forward or backward during filming, or your zoom level changed, or your camera tilted (perhaps slightly, as when on a tripod in the wind) you may need to select "Scale" or "Rotation". Selecting "Scale" or "Rotation" will cause an additional tracker to appear. Try to set it up as far from the first tracker as possible, while still following all of the same basic rules. After Effects needs this second tracker to analyze scale or rotation since these translations are relative to a secondary point. You will also see this additional tracker in the timeline. Keep this in mind if you start deleting keyframes. Once you're ready, click the "Apply" button in the "Tracker" panel. "X and Y" is usually a fine option, so just click "OK".

You should now be able to render the composition and see your footage, well aligned and stabilized- hopefully looking much better!
Slowing it Down
Generally speaking, with the right equipent and proper planning, there should be no need to slow good time lapse footage down any further. If you can, just do the math in advance. Start by ansering these three questions:
  • How many frames per second are you going to want? (aim for 30)
  • How long do you want the end movie to be?
  • How long is your event (e.g. 24 hours, 30 minute sunset, 3-week plant wilting)
Use this equation to configure the delay on your intervalometer:
Delay in seconds = "length of event in seconds" /
("length of movie in seconds" x "frames per second")
So, for instance, if I am recording 8 hours worth of clouds, and I want a video that is 30 frames per second and 15 seconds long, that would give me:
Delay in seconds = (8 hours x 60 minutes / hour x 60 seconds / minute) /
(15 seconds x 30 frames per second)
Photos / second = 28800 seconds / 450 frames
Photos / second = 64
If your camera and intervalomter can handle delays in seconds, then good for you! If not, round this down to the nearest minute. The built-in intervalomter on my wife's Canon has a delay specified in minutes- so one minute is as fast as it can go. I imagine this is probably the case for many intervalometers.

So, as you can see here, 15 seconds is about all the footage I will get from this camera at 30 frames per second from an an 8-hour span. That's quite a time compression! If you're not happy with that, there are a few things you can do in post production to stretch out your footage.
Change the Frame Rate
Quicktime Pro, After Effects, and just about any other video editing software should let you change the frame rate of a video file, or re-export it video with a new frame rate. For instance, lowering the frame rate to 15FPS (or, rendering it at that frame rate in the first place!) will double the length of a 30FPS video.

Once you get much below 10FPS, your eye will probably start to pick up on it, and it will look "jittery". This is because your eye is finding it easier to pick out individual frames, and the transition between each one becomes less blurred and fluid. Eventually, it will literally start looking like a slideshow. Which might be pretty, but that's another tutorial alltogether.
Using Time Warp in After Effects
After Effects has an effect called "Time Warp" that can speed up or slow down a clip. The cool thing about this effect is that it will create interpolated frames for you. What does that mean, you ask?

It means that, if you use "Time Warp" with the "Speed" variable set to "50%" (the default), your clip will get twice as long (and twice as slow). But- and here's the magic part- the framerate will stay the same (say, 30FPS).

After Effects does this by inserting a new frame in between each frame of your video footage. It creates this frame by intelligently (more or less) combining the surrounding frames.

Here is an example of time warp in action, using some video of my daughter. I slowed this video down by 50%, and then compared two frames with the new frame that was created in between them. Note that, in the new video, every other frame is an interpolated frame.
Frame
Original Time 46;26 N/A 46;27
Interpolated Time 1:33;22 1:33;23 1:33;24
You can see that After Effects does a pretty good job (in most cases) of blending the two frames. Sometimes things get a little blurry or watery looking, but you don't notice this so much when the video is in motion. I have had limited success going much slower than 50%, however- once your interpolated frames start outnumbering the real onces, the effects gets really noticeable. I'll cover this more in-depth in a later post specifically about time warping.

Let's walk through the math used to get the times listed above, and how to compare frames before and after time warping. For instance, if you want to find the frame that was previously at "46;27" in your new timewarped video, you have to apply the inverse of your time scaling factor. Or, another way to look at it, divide by the time scaling factor.

In this case, my time scale is 50% - meaning I need to divide by 50%, or multiply by 2. Fortunately, After Effects will do the hardest part of this math for you. Simply multiply both numbers by 2, and plug those values into After Effects: "46;27" x 2 = "92;54", which After Effects correctly translates into "1:33;24".

Now, if you're smart, you'll catch something I can't quite explain- to grab the interpolated frame, I actually had to go to 1:33;25 - two frames later than I thought. I'll report back here when I figure out why that is. To add the time warp effect to your footage, right-click and find it under "Effect", then "Time". The "Effect Controls" panel will appear. Here you can control the current effect, in this case "Time Warp". The two most important controls here are "Method" and "Speed". "Speed" is the percentage at which the effected video will play- so "50%" means it will play at half speed.

The values for "Method" are as follows:
  • Pixel Motion Creates a new frame by analyzing the pixel movement in nearby frames and creating motion vectors.
  • Frame Mix Creates a new frame by blending existing frames.
  • Whole Frames Duplicates the last frame shown.
That's the offical word, anyway. My take on it is this:
  • Pixel MotionThis can create the biggest "wow" effect, if it works well. If it works poorly, it creates weird watery effects that can be very noticeable.
  • Frame MixThis method can work very well with motion blur, as long as you don't mind the motion looking really blurry.
  • Whole FramesThis is basically the cheap method- it's barely a step up from just lowering the frame rate.
As always, experiment with each option and see what looks best for you and your particular situation. Effects will also appear in the timeline. Anything with a "stopwatch" icon, such as "Speed", can be keyframed. This button, in the timeline controls, will toggle automatic keyframe creation. With this on, any change you make (such as moving a layer, or changing "Speed" in the "Time Warp" effects) will be stored in a keyframe. When the video is rendered, keyframed values transition smoothly from one keyframe value to the next.

By keyframing the "Speed" variable you can create some dramatic effects with time- this will be a topic for a later post.

Once you have your time warp effect configured, you may need to adjust the length of your clip. In particular, if you've slowed down footage- your clip is now longer, and you may need to account for that. Right-click on your clip in the timeline, and select "Enable Time Remapping", in the "Time" menu. This will allow you to "resize" your clip in the timeline. Click on the right end of your clip in the timeline, and drag it to the right to resize it. If you've slowed your clip down 50%, you'll need to make it twice as long if you want all of the footage to appear in the timeline.

Do not modify the "Time Remap" keyframes. That is an alternate way to re-scale time, but it doesn't provide as much control as the time warp effect. You will now need to find the new end time of your movie, and set your Output composition length accordingly. For a straight 50% time warp, it's as simple as doubling the original length- but it gets much more complex when you start keyframing the speed.

You can now render the composition to see your slowed-down footage. Keep an eye out for any strange-looking artifacts!
Adding Pan and Zoom
If you have a camera with more than a few megapixels worth of resolution (and you should!) you may notice that, even when outputting in 1080p, you've got a lot of extra frame to play with. You can simply downscale it, of course- or, if you don't mind getting a little cheesy, you can have some fun with those extra pixels.

Select your Output layer, and expand its timeline. You may or may not see one more or more motion trackers in there- but below that, you will see a "Transform" section. Turning on the "Auto Keyframe" feature makes animation in After Effects easy. This means that any changes you make to your layers are recorded in a keyframe at the selected time.

Scrub through your timeline to find an interesting point, then resize and move your frame.

You'll notice keyframes are created each time you do this. When you play the video, After Effects will smoothly zoom and pan between your keyframes.

Keep an eye out for times when one of your sequences goes out of frame- you'll see black bars appear on the side of your screen. Adjust your keyframes to keep your frame filled at all times.

At this point, I've covered everything I did to my first time lapse, for better or worse! If you haven't rendered your experiment already, do it now and see what you've got!
Render Sequence in After Effects
When you are finished with your After Effects project, or if you just want to check your progress, you'll want to render your output composition.

With your Output composition selected, use the "Make Movie" menu item, under "Composition". This will add a new item to your render queue. Press the "Render" button to begin rendering to a file.

You can expand items in the render queue to change output settings. In particular, you may want to compress the output (H.264 is always a good choice). For me, I know that I am taking this footage and putting it in iMovie. To avoid double compression, I'm going to leave the output uncompressed. Note that uncompressed video is quite large, so this may not be an appropriate choice. Once I've learned to use After Effects more extensively, I will no longer use iMovie and instead output compressed video straight from After Effects.

By default, the file will have the composition name ("Output" in our case) and be saved to your desktop. Go find the file, and enjoy your results!

1 comment:

  1. Whew! Well over a week after I first published it, I've finally finished my first post.

    I may have bit off more than I could chew with this one, and I definitely published it prematurely. But, I'm happy with the result. There's a lot of good information here, if you're willing to learn from my mistakes (and care to learn this one particular thing I've documented in excruciating detail!)

    So, did you make it all the way through? Have any thoughts? Please, leave a comment!

    ReplyDelete