Add marker to 2D tracking list via clip.stabilize_2d_add() or other means My goal is to call blender form the command line with a set of arguments to use the built in 2D video stabilization tools.

I have been able to (via the bpy API):


Get parameters from command line call
load a new clip
add a marker (to track)
position the marker
'select' the marker/track (not sure if needed)


This is all possible without relying on bpy.ops 

Unfortunately now I need to access the following functionality programmatically:



My main question: I can't find a way to get to that (bpy.ops.clip.stabilize_2d_add()). I have no idea what context I would need to switch to to make this a valid python call.



At this point I also notice the transition from doing everything in code to having to hunt through the UI workflow for ways to replicate UI functionality. I am wondering if I shouldn't need to call bpy.ops.clip.stabilize_2d_add() at all and should instead find the underlying functionality? 

The part that comes right after this, which is making the stabilized track is completely lost to me as well. Am I going in the wrong direction?

Any help would be greatly appreciated.
You can add and adjust tracking markers without using operators.

Each movie clip has a tracking property which has a list of the tracks that have markers.

Every tracking.track is a point in that you are tracking. The markers for each track are keyframes of the tracks location.

import bpy

track_data = bpy.data.movieclips['movie_track'].tracking

for i in range(10):
    # this adds a new point to be tracked
    trck = track_data.tracks.new()
    for f in range(1,100,10):
        # this sets the location of the point at frame f
        x = (f+i) * 0.1
        y = (f+i) * 0.1
        trck.markers.insert_frame(f, co=(x,y))

# get track data
for t in track_data.tracks:
    for m in t.markers:
        print('marker on frame {} at {}'.format(m.frame, m.co))