How to make the camera move with the object while animating
A camera in the real world rarely tracks directly onto the subject - it will typically lag behind the motion of the subject so that the faster the subject moves, the further the camera will become out of position before it can catch up and the nearer to the edge of the frame it will be. We can emulate this effect by tracking the camera to Empties that follow behind the object rather than to the object itself.

Add two Empties to the scene - one will be the point the camera is pointing at (target), the other will be the 'ideal' position of the camera (goal). The 'goal' can be parented to the object so that it stays at a fixed position in relation to the object being tracked - in this way the camera can be made to follow the object at a fixed distance and direction. A Track To constraint on the camera will point it at the 'target' Empty.



Drivers will be used to re-position the camera and the 'target' on each frame.

To achieve this, select the 'target' Empty, right-click one of the Location fields in the properties panel (N) and select 'Add Drivers'. Open a Graph Editor window and change the mode to 'Drivers' - you should see the three drivers for the X, Y, Z location. For the X Location, the default 'var' variable should already default and set to Transform Channel for X Location - set the 'Object' to the object being tracked. Create a second variable named 'self' and similarly set to Transform Channel and X Location - set its 'Object' to the 'target' Empty. Set the driver expression to '(var + self * 4)/5.

NOTE : To enable driver expressions you may need to go into File/User Preferences/File and enable Auto Run Python Scripts.



Repeat for each of the Y and Z locations, changing the Transform Channel to the relevant channel in each case (ie, Y Location for 'Y' and Z Location for 'Z').

The expression (var + self * 4)/5 calculates a point that is 1/5th of the way between the Empty and the object being tracked and the Empty will now move to that calculated position on each frame. This will mean that the Empty will gradually move towards the object being tracked and will lag behind the object as the object moves.

Moving the object using keyframes should now result in the camera tracking to the object with a slight lag when you run the animation. The lag will be greater the faster the object is moving.

Set up similar drivers for the Camera (ie, select Camera, right-click a Location property, Add Drivers, go into the Graph editor and set up the drivers with Object set to the 'goal' empty (var) and the Camera (self)). 

To increase the lag in the calculated postions you can adjust the calculation - for example '(var + self * 9)/10' will move it 1/10th of the distance, '(var + self * 19)/20' would move it 1/20th of the distance - so it would take much longer to reach the goal.

If you now run the animation you should find that the camera attempts to move with the tracked object and attempts to keep it in the centre of the shot.



NOTE : As the object positions are calculated 'on-the-fly' you can get unexpected results if the frame number jumps forward/backward or blender calculates sub-frames (as the calculated positions will still move as if a single frame has advanced). Therefore, it's a good idea to Bake the animation prior to rendering by selecting each of the 'dynamic' objects in turn (ie, the 'target' Empty and the Camera) and go to Object/Animation/Bake Action in the 3d-view menu. Once baked to keyframes you should disable the drivers by clicking the image of a speaker in the Drivers view.




Blend file attached