Movieclips and Tracking
Movieclips contain a reference to a MovieTracking data structure. That tracking data contains a list of tracked objects, always containing a camera as the first object (These don't correlate to scene objects!). Each object can have multiple tracker objects. Each track object has one marker object for each keyframe. That marker object finally stores the location of that tracker at that certain frame as a percentage.
Movieclip → MovieTracking → MovieTrackingObject → MovieTrackingTrack → MovieTrackingMarker
Here's a script that lists these data points:
for clip in bpy.data.movieclips:
print(f"Clip {clip.name}: {len(clip.tracking.objects)} tracking objects.")
print(f"Size: {clip.size[0]}x{clip.size[1]}")
width = clip.size[0] # 848
height = clip.size[1] # 480
for obj in clip.tracking.objects:
print(f" - Object {obj.name}")
for track in obj.tracks:
print(f" -- Track {track.name}: {len(track.markers)}")
for marker in track.markers:
print(f" --- {marker.frame}: {marker.co[0]:4.2f} x {marker.co[1]:4.2f}")
This is how you add a new track:
clip = bpy.data.movieclips["RightTopCamClip"]
width = clip.size[0]
height = clip.size[1]
bpy.ops.clip.add_marker(location=(424.0/width,240.0/height))
This is how you insert new frames:
clip = bpy.data.movieclips["RightTopCamClip"]
track = clip.tracking.objects[0].tracks[0]
track.markers.insert_frame(10, co=(212.0/width,120.0/height))