How can I get the x,y location of an object at each frame of animation?
Here is the code from https://blender.stackexchange.com/a/14746/15543 slightly modified to make the region and region_3d global and put the area into camera view.

import bpy

from bpy_extras.view3d_utils import location_3d_to_region_2d

def view3d_find():
    # returns first 3d view, normally we get from context
    for area in bpy.context.window.screen.areas:
        if area.type == 'VIEW_3D':
            v3d = area.spaces[0]
            rv3d = v3d.region_3d
            for region in area.regions:
                if region.type == 'WINDOW':
                    return region, rv3d
    return None, None

region, rv3d = view3d_find()
# put the region into camera perspective
rv3d.view_perspective = 'CAMERA'

def view3d_camera_border(scene):
    obj = scene.camera
    cam = obj.data
    frame = cam.view_frame(scene)
    # move into object space
    frame = [obj.matrix_world * v for v in frame]
    # move into pixelspace
    frame_px = [location_3d_to_region_2d(region, rv3d, v) for v in frame]
    return frame_px

frame_px = view3d_camera_border(bpy.context.scene)
print("Camera frame:", frame_px)


This gives us the 2d region coordinates of what will be the rendered scene.
If we take out the smallest of these coords we are mapping to "region camera coords" only vectors in (0, 0) to max(cambounds) will be in rendered image.

# this is the camera bounds
blc = min(frame_px)
cambounds = [v - blc for v in frame_px]
print("camera is on screen as :", max(cambounds))


I get as a test case: my render resolution (scene.render.resolution_x, .. resolution_y) is  1920 x 1080 (the ratio x/y = 1.777)


  camera is on screen as : &lt;Vector (328.3195, 184.6790)&gt;


ie the camera rectangle you see in view3d window has size 328 x 184 which has the same ratio.  So all vectors below, like for instance objloc can be multiplied by (1920 / 328.3195) to return them as pixel coords of the rendered image. (nb not taking into account resolution_percentage and non square pixels)

Similarly for object location.

# object location
obj = bpy.context.object # the context object.
objloc = location_3d_to_region_2d(
                      region,
                      rv3d,
                      obj.matrix_world.to_translation()) - blc
print(objloc)


And a quick object bounds using bounding box, get the 2d coords from the 8 3d corners of the bounding box.

bounding_box = [v[:] for v in obj.bound_box]
bbox_px = [location_3d_to_region_2d(region, rv3d, v) 
                         - blc for v in bounding_box]

min_x = min(v.x for v in bbox_px)
max_x = max(v.x for v in bbox_px)
bbox_width = max_x - min_x 

#... etc to get the coords of bbox.


or this could be done by looping thru the verts of the object

mw = obj.matrix_world
#global vert locs
verts = [mw * v.co for v in obj.data.vertices]
# vert locations in "region camera coords"
verts_px = [location_3d_to_region_2d(region, rv3d, v) 
                         - blc for v in verts]


and finding the min max for x, y as above for bounding box.  

Note haven't put in code to loop thru frames and write to output file as that is trivial, it's the camera bounds that is difficult, but fortunately handed to us via ideasman42's answer.