Reduce the Size of Large Motion Capture Animations

Reduce the size of animations produced via motion capture (e.g. Mixamo) by removing duplicate keyframes

Background

Using tools like Mixamo is great for getting realistic, potentially complex animations for NPCs. However, they use motion capture to create the animations, which creates a TON of keyframes and poses, even when there’s essentially no difference from one frame to the next. This causes bloat in the memory used by your game and causes a rapid rise in the number of instances managed by your game.

So what I did was I wrote a PowerShell script to read the exported animation (.rbxmx file), and then starting at the beginning of the time sequence, move forward and compare the part positions in each sequential keyframe and determine if it had moved enough to warrant a new keyframe. If not, that entry is removed. It goes through the entire animnation part by part, comparing CFrames with a precision of 0.01. Any movement less than that amount is considered discardable.

Why PowerShell and not a Studio plugin? Easy - the instances of keyframes and Poses within Studio do not expose all of the actual position properties that are available in the exported RBXMX file. So it’s not physically possible within Studio. Exporting the animation as an RBXMX is simple enough, and re-importing the modified file is also simple. The hardest part for most people using this tool will be using PowerShell :slight_smile:

Results

I have achieved anywhere from 15% to 50% reduction in the size of animations this has been run against, with no appreciable loss in quality of the animation itself. Greater reductions are achieved when there is relatively little motion for most of the character such as an idle animation. Lower reduction percentages happen when there is a lot of motion of all of the parts of the character, such as shaking.

Note that reducing the overall number of animated part keyframes in your animation can also have the effect of actually letting you edit it in the Roblox animation editor. When you have too many keyframes in an animation, the editor simply draws a line all the way across for the part, rending it just about un-editable. As you’ll see from the examples below, reducing keyframes can help you overcome this.

Examples:

Idle animation - previous version with 1594 instances

image

Idle animation - new version with 991 instances (38% reduction)

image

Old animation with 6,283 instances

image

New Animation with 3,653 instances (42% reduction)

image

Usage

To use this tool:

  1. Within Roblox Studio, open your character in Explorer and select an animation from inside the AnimSaves model
    image
  2. Right-click and select “Save to File”, enter a file name, and make sure “Save as type” has Roblox XML Model Files (*.rbxmx) selected, and click Save . Be sure to rename your old animation after exporting for safe-keeping.
  3. Run the PowerShell script in your favorite PowerShell editor and it will prompt you to select the file to process. Select what you just exported.
  4. The PowerShell script will run and output some info to the console output. When done, you will have a new file named (yourfilename)_New.rbxmx .
  5. Go back into Studio and right-click the AnimSaves model, then select Insert from File and then select the file just created and click Open . Your new animation should now be playable via Animation Editor.

Where To Get This Tool

15 Likes

How do you use something like Mixamo with roblox rigs? Is there some sort of converter?

I know that you can export a rig from Roblox as .OBJ and import into Mixamo. See the proof below:

https://gyazo.com/9ad6a64147a1663a8e6a6a6e7298549e

The problem is that even if you import your Roblox rig into Mixamo, the FBX you get back out has all of the bones named “mixamorig:{bonename}” (e.g. mixamorig:RightArm). So when you try to import them using Animation editor, they don’t work.

I could write another script that would rename all of the bones in the animation to something that would work with RTHRO or R15 rigs. I’ll see what I can do.

1 Like

Here is my less than successful first attempt at converting a Mixamo animation to an R15 rig.
:rofl:

https://gyazo.com/7a7dc6187b2cbdf4a3c9b4bb8120703c

Wow, that is incredible. Everything starts somewhere though. Although you could probably import a mixamo rig to Roblox.

If you want to go thru Blender first you can do it much easier.