Re-align imported animation keyframes to blender frames

I've imported a motion capture armature from an fbx file, the problem is whenever I check the action number of keyframes for any fcurve they are much more than I expected from previewing the action keyframes in dope sheet (the action starts at frame 1)

The keyframes timing is not aligned to blender frames as well.

I could fix this manually by selecting all the keyframes in the dope sheet editor, press g to move them then left click, this snaps all keyframes to their correct location in the timeline and when I recalculate the number of keyframes I get the expected number of keyframes. Is there a way to replicate the same process in python?

• Yes there is. Buy maybe your question should be: How can i...? ;) Jun 12, 2021 at 12:30
• Firstly it is not vital that kfs be exactly on frames, as long as the action time is same mocap will look Ok . A bvh often has a very high frame rate eg 100 frames per second. Which if imported "raw" at default 24fps will have 100 kfs jammed into 24. Since the Importers use the bvh timing. (bvh importer has options not to) Some options Set blender fps to match. Set a frame rate multiple eg 25 fps keep 1 & cull 3 of each 4. Clean and smooth the fcurves (wont put kfs on exact frames will cull a lot) Can make a new action with copy of fcurves by using Fcurve.evaluate(frame) Jun 12, 2021 at 13:20