import bpy
D = bpy.data
for clip in D.movieclips:
for track in clip.tracking.tracks:
fn = 'data/tr_{0}_{1}.csv'.format(clip.name.split('.')[0], track.name)
with open(fn, 'w') as f:
frameno = 0
while True:
markerAtFrame = track.markers.find_frame(frameno)
if not markerAtFrame:
break
frameno += 1
coords = markerAtFrame.co.xy
f.write('{0} {1}\n'.format(coords[0], coords[1]))
Careful: The coordinate output is in units of the video height / width. So if your video is not square sized, you need to multiply the output by the video clip dimensions (clip.size[0] and clip.size[1]).