How to make a script with Motion Tracking

Introduction

Here’s a walkthrough of scripting an animated scene with the help of Motion Tracking Funscript Generator v0.5.x by @mchyxnaaiorxfwrivv. Please find the finished script in the following post:

Note that although motion tracking is used to plot majority of the actions, the final result is still heavily modified by hand, including the addition of all the vibrations and curves. Motion tracking cannot do everything for you, but will cuts you from the boring task such as going through each frame for the perfect sync.

Ingredients

Process

Step0 - Rename the Video File

image
image

Unfortunately the plugin does not support path name with special characters yet. Start by renaming your file if it contains any.

Step1 - Divide the Scene into Segments

Watch the scene and identify sections that can be motion tracked, think how you may track them.

  • Hand - Handjob. Track hand on y-axis.
  • Sex - Track features of both actors.
  • Grind - Track x-axis movement.
  • Skip - Skip and script manually.

Check this option, then add a point to the end of each section. The plugin will then know where to stop.
image

Step2 - Motion Tracking

Start MTFG & Apply Settings

Start MTFG at the beginning of a section.
image

Adjust settings according to your need. In the case for the handjob section, there is a static camera, a single feature (hand) moving up and down. I can use the following settings.
image

Select ROI and tracking feature

If using the mouse menu, drag a box around the tracking area, hit space, then select the feature to track.

Hit space again to begin tracking.
mousemenu

Tracking Two Actors

For the sex sections both actors are moving on the y-axis. We can use “Two moving persons” as the tracking method. This will output the y-axis distance between the two tracking feature.
time1
image

Put the tracker boxes on the testicles and anus.

track1

Skipped Sections

I manually scripted a few sections because they are not ideal for motion tracking.

This section is difficult to track due to a few camera switches. The tricky angle also obscures trackable features. Since it’s an animation with repeating actions, we could simply repeat data from previous scenes.
manual1

If there are frames where tracked features are obstructed, tracker can end up elsewhere and mess up the result.
ntr

Particles blocked the features in these few frames, so I stopped tracking prior to them for good.
notrack

Step3 - Post-processing

After selecting the range of your raw data, you’ll be prompted with Post-processing. Unless you make the script exclusively for OSR2 / SR6, you will want to reduce the immense number of points in this step.

The first two tabs filters the points with named functions respectively, it’s quite straightforward, drag their sliders to see the effect.
image
drag

If the result aren’t desirable, attend the “Custom” tab for more control over the filter. Here’s how to generate a simple script based on the minimum and maximum points:

Select Local Min Max

Adjust the Filter Length. In this instance I’m turning it down to 0.

You’ll then have a clean result with top and bottom points only.
image

Click Okay and insert the result to our timeline.
image

Manually tweak it to your liking.
image

There’s more to the custom tab which can be used to fine tune the result. Which I’ll explain by the end of the post.

Step4 - Salt & Pepper to Taste

Motion tracking can be very accurate in terms of timing, but usually isn’t very good at determining the desired stroke length. The following motion tracked result is true to the video, sadly nobody can feel. You should manually adjust the stroke length until you see fit.
short

Post-processing once sometimes isn’t enough. After inserting to timeline, clean up unnecessary points if they still exists. You can use OFS’s Simplify function on smaller parts of the script, or manually deleting points.
RDP

I recommend using motion tracking to draft out the basic movements, then add in details over it. This way it will saves you from the headache of frame-to-frame scripting.

Always revise your script before publishing, test it out and touch it up.


Tips & Tricks

Processing Speed

If there are fast movements, you may wanna set the processing speed to 0 (accurate).
This will process every frame to prevent action lost due to processing intervals.
speedimage
Vise-versa. For slow movements, 2 (fast) is usually enough.

Keyboard Menu

It’s much more convenient to use the mouse menu, however keyboard menu offers you the ability to rotate your viewpoint. This way you can align the motion to an axis, then track using y/x-axis tracking metric.

Supervised Tracking

You can select “Supervised Tracking” under Tracking Method. This will allow you to define an bounding area where the tracking features should stay in.

  • Supervised Stopping will stop tracking when the feature leaves the area.
  • Supervised Ignore will ignore data produced when the feature is outside of the area.
    image

This could be useful if you are tracking a long film with occasional camera switches, or videos where the couples disengage from time to time.

Read more about this feature on github.

Track Anything

It is intuitive to track the genitalia. But pretty much anything moving with the actor will work. In the following case the vulva and anus are both obstructed. I placed the tracker on the buckle instead. Since the tracking metric is set to y (up-down), only verticle displacement will be taken into account.

buckle

Try placing the tracker on belly button, public hair, tattoos, nose etc. Just make sure it is some kind of distinct feature, and they are moving in sync with the actor.

Advanced Post-processing

If some strokes got accidentally filtered out by post-processing, or you just like preserving more points in your script, you can allow in more points by modifying parameters under Additional Points.

I can’t dig into the details for each (the dev probably can), just speaking from experience:

Max Iterations - Higher the value, more points allowed.
Merge Threshold Time - Lower the value, more points allowed.
Merge Threshold Distance - Lower the value, more points allowed.

Second Derivate
image

Distance Minimization
I personally found this one the most useful.

Evenly Intermediate
This allows points at the middle of a stroke. Affected significantly by Max Iterations.
image

You can create a somewhat smooth curve with settings like the following:

93 Likes

animation

8 Likes

Awesome case-study.

Now if only I could get it to run on macos. The funscripting community doesn’t show a lot of love to rotten fruit.

2 Likes

This is NOICCEEEEEEEEEEE

Another tip I’ve learned recently:

Try to track fast sections separately from slow section. Fast strokes usually requires less point whilst slower strokes may need more. Track them individually so you can apply different post-processing parameters to each.

Slow section (I tweaked the custom filter to include more points)

Fast section (I left it to default to get a basic triangle wave)
image

2 Likes

Hey great post! Why doesn’t my post-processing window show the action based on post-processing tweaks?

1 Like

hmm, try resize the window by dragging its corner?

3 Likes

lol. fuck me. yup that did it. thanks! :sweat_smile:

Is there a way to share a Mac app? I ported it over to Mac OS (m1) how can I share to test it?

Is it better to draw bigger or smaller boxes for tracking?

1 Like

Damn, I had no idea about the viewpoint rotation lol
Learning all sorts of tricks today from these threads.

edit
Finally upgraded to the new version. The custom settings for the smooth curve is a great addition.

Thanks, this makes it so much easier to script now without doing manually.

1 Like

After running the motion tracking, it does not input the data back into the main script window. Any help would be appreciated

I guess how do I insert into the timeline?

Provide the following Information/Outputs so we can help you:

  • Enable in OFS Topbar Extensions : Show log
  • Enable the Checkbox Enable logging in the OFS MTFG extension Widget.

Then start the MTFG with Start MTFG Button …

When completed (where you stuck with missing data in OFS) provide the output of OFS Extension log. In addition use the Button Open Log from OFS MTFG Extension Widget (This button appears when you have execute the MTFG once with enabled logging).

With this information we may be able to help you.

Additional Note: You can also try the force Import button.

how do you make chapters/segment. i will try but i cant create variable chapter. is always 26 secons long. pls help me

Create the chapter at the start of the segment you want then go to the point in the video you want the chapter to end. Right click the chapter blob and click set size.

1 Like

thank you so much

I have an issue with it tracking for more that 56 seconds. It stops at 56 second intervals. It isn’t scene change, I’ve tested it on different videos with scenes that are steady and continuous movement in the same direction… I can’t get this to track the motion for longer than a minute.

It must be a setting or something I’m doing wrong

Is there a sudden movement at 56 seconds mark? Sometimes the motion is so fast that the tracker lost it. Try setting speed to ‘‘0 (accurate)’’ will also help in that case.