#!/usr/bin/env python3 """Decide whether a binary FBX actually contains motion. Keyframe *count* says nothing: a clip can carry 91 keys that all hold the same value. This decodes the `KeyValueFloat` arrays of every animation curve (FBX stores them zlib-compressed) and reports the largest peak-to-peak range found. A file whose every curve is flat is static. """ import os, struct, sys, zlib SCALAR = {"Y": 2, "C": 1, "I": 4, "F": 4, "D": 8, "L": 8} ELEM = {"f": 4, "d": 8, "l": 8, "i": 4, "b": 1} FMT = {"f": "f", "d": "d", "l": "q", "i": "i", "b": "b"} def probe(path, eps=1e-6): d = open(path, "rb").read() if d[:21] != b"Kaydara FBX Binary \x00": raise ValueError("not a binary FBX") version = struct.unpack("= 7500 NREC = 25 if u64 else 13 curves = [] # (name, peak-to-peak range, n) def rd_prop(p, want_values): t = chr(d[p]); s = p; p += 1 if t in SCALAR: p += SCALAR[t]; return p, (t, d[s + 1:p]) if t in ELEM: n, enc, clen = struct.unpack(" eps), "static": bool(ranges) and max(ranges) <= eps, "no_curves": not ranges, } if __name__ == "__main__": for f in sys.argv[1:]: try: r = probe(f) print("%-40s curves=%-5d moving=%-5d max_range=%-12.6g %s" % ( os.path.basename(f), r["num_curves"], r["moving_curves"], r["max_range"], "STATIC" if r["static"] else ("NO_CURVES" if r["no_curves"] else ""))) except Exception as e: print("%-40s ERROR %s" % (os.path.basename(f), str(e)[:50]))