From c231241f649b743952462b0c4ea00b071af7a49a Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Mon, 18 Apr 2022 15:42:03 +0200 Subject: [PATCH] Initial commit. --- README.md | 10 ++++++++++ ktx-stats.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 README.md create mode 100644 ktx-stats.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..d9dba22 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +KTX Stats Extractor +------------------- + +Extract embedded JSON statistics to `somedemo.json`: + +``` +./ktx-stats.py somedemo.mvd +``` + +For more details see `stats.c` in the [KTX repository](https://github.com/QW-Group/ktx). diff --git a/ktx-stats.py b/ktx-stats.py new file mode 100644 index 0000000..0c22aaa --- /dev/null +++ b/ktx-stats.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import struct +import json +import sys +import os + +with open(sys.argv[1], "rb") as fd: + data = fd.read() + +offset = data.rfind(b"\x0a\x00\x00\x03\x00\x00\x00\x00") +offset += 2 + +content = b"" + +while data[offset:offset + 4] == b"\x00\x03\x00\x00": + (length,) = struct.unpack("