Adobe After Effects has motion tracking controls which allow you to track the motion of a specific point, like a light, on your footage. Once you do that, it's easy to attach your Control Layer's position to that point so that your lens flare automatically moves with your footage. You can also use the Control Layer's Motion Tracking Offset control to have extra control over your lens flare's position.
With your footage layer selected, go to the Window drop-down menu and choose Tracker Controls. A new panel opens up. Click Track Motion and a new Composition panel opens with your footage in it, and a small tracking box on your footage. Be sure to go to the beginning of where you want to start tracking on your timeline. Click and drag the tracking box to go over the point you want to track. The tracking box is made of two squares. Scale the inner square to include an area of high contrast that After Effects will be able to follow, and adjust the outer square to include the area that After Effects should search in each frame for that point of contrast. If your footage is shaky or moves around a lot, this square will need to be bigger. With the tracking box in position, hit the Play button in the Tracking Controls panel, and let it track the motion. When you've tracked enough, click the Stop button. All that's left to do now is hit Apply, and it will send the tracking data to your top layer by default, which is your Control Layer. And if you open the Position parameter of your Control Layer, you'll see a bunch of keyframes.
You will probably run into situations where the point that you want to track doesn't have enough contrast in it for After Effects to track it. Say for example that you wanted to put a lens flare light up in a blue sky in your footage. After Effects can't track a point on a solid color if there's no contrast. What you can do is motion track an area on the ground, then use the Motion Tracking Offset control, found on the Control Layer, to move the light up into the sky.
Once you've motion tracked a point on the ground, you're ready to offset the track point so it moves to an area of the sky. Selecting the Control Layer and adjusting the Motion Tracking Offset control at this point doesn't do anything. We first need to put an expression in the Position parameter of the Control Layer in order for the offset control to work. The expression is very simple. First, open the expression box by alt-clicking the stopwatch icon for the Motion Tracking Offset control. Type "value+" in the box. Before you leave the expression box, you need to add a link to the offset point control, and we do that by dragging the pickwhip icon (little swirly icon) to the Motion Tracking Offset control where it says Point. The entire expression should now say value+effect("Motion Tracking Offset")("Point"). If you would rather cut and paste the expression, you can find it in the Comments column of the Control Layer.
Now you are ready to offset your point. The point cursor in the control won't work, so instead, click and drag the coordinate values and you'll be able to see you tracking box move.
Click on a topic or subtopic to learn more.