Python bindings for subtr-actor, a Rocket League replay processing library.
pip install subtr-actor-pyimport subtr_actor
replay_path = "path/to/replay.replay"
# Parse raw replay bytes into the full replay structure.
with open(replay_path, "rb") as replay_file:
replay = subtr_actor.parse_replay(replay_file.read())
# Build a numpy ndarray plus metadata.
meta, ndarray = subtr_actor.get_ndarray_with_info_from_replay_filepath(
replay_path,
global_feature_adders=["BallRigidBody", "SecondsRemaining"],
player_feature_adders=["PlayerRigidBody", "PlayerBoost", "PlayerAnyJump"],
fps=10.0,
dtype="float32",
)
headers = subtr_actor.get_column_headers(
global_feature_adders=["BallRigidBody", "SecondsRemaining"],
player_feature_adders=["PlayerRigidBody", "PlayerBoost"],
)
replay_meta = subtr_actor.get_replay_meta(replay_path)
frames_data = subtr_actor.get_replay_frames_data(replay_path)
stats_module_names = subtr_actor.get_stats_module_names()
stats = subtr_actor.get_stats(replay_path, module_names=["core", "boost", "movement"])
stats_snapshot_data = subtr_actor.get_stats_snapshot_data(
replay_path,
module_names=["core", "boost"],
frame_step_seconds=1.0,
)
stats_timeline = subtr_actor.get_stats_timeline(
replay_path,
frame_step_seconds=1.0,
)
legacy_stats_timeline = subtr_actor.get_legacy_stats_timeline(
replay_path,
module_names=["core", "boost", "movement"],
frame_step_seconds=1.0,
)
print(ndarray.shape)
print(headers["player_headers"][:5])
print(replay_meta["map_name"])
print(stats_module_names)
print(stats["modules"]["core"]["team_zero"]["score"])
print(stats_snapshot_data["frames"][-1]["modules"]["boost"]["team_zero"]["amount_collected"])
print(stats_timeline["events"]["boost_ledger"][-1])
print(legacy_stats_timeline["frames"][-1]["team_zero"]["boost"]["amount_collected"])get_stats_timeline is the compact event-backed timeline. Its frames contain
timing, gameplay state, and player identity scaffolding only; stat deltas live
under events. Use get_legacy_stats_timeline only for compatibility code that
still needs serialized per-frame team/player snapshots.
Parse raw replay bytes and return the full replay structure as Python data.
get_ndarray_with_info_from_replay_filepath(filepath, global_feature_adders=None, player_feature_adders=None, fps=None, dtype=None) -> tuple[dict, numpy.ndarray]
Process a replay file and return metadata plus a numpy.ndarray.
Parameters:
filepath: path to the replay fileglobal_feature_adders: list of global feature names, default["BallRigidBody"]player_feature_adders: list of player feature names, default["PlayerRigidBody", "PlayerBoost", "PlayerAnyJump"]fps: target FPS for resampling, default10.0dtype: output dtype string. Supported values arefloat16/f16/half,float32/f32, andfloat64/f64/double
Get replay metadata and ndarray headers without materializing the full ndarray.
Get header information for the configured ndarray layout.
Get structured frame-by-frame game state data with no FPS resampling.
List the builtin stats modules that can be selected in get_stats,
get_stats_snapshot_data, and get_legacy_stats_timeline.
Get aggregate replay stats for the selected builtin modules.
Parameters:
filepath: path to the replay filemodule_names: optional list of builtin stats module names. By default all builtin modules are included.
Get the raw stats snapshot payload produced by StatsCollector, including:
config: module configuration emitted by the selected stats modulesmodules: aggregate module outputsframes: per-sample module snapshots keyed by module name
Parameters:
filepath: path to the replay filemodule_names: optional list of builtin stats module names. By default all builtin modules are included.frame_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.
Get the compact event-backed stats timeline for each replay sample.
Frames contain timing, gameplay state, and player identity scaffolding only;
stat state changes are transferred through events, and full team/player
snapshots can be derived by clients that need them.
Parameters:
filepath: path to the replay fileframe_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.
module_names filtering is not supported for compact event timelines. Passing
it raises ValueError; use get_legacy_stats_timeline if filtered full
snapshot timelines are needed.
Get cumulative typed stats snapshots for each replay sample.
This preserves the pre-compact timeline behavior for compatibility and for explicit parity checks, but it serializes the full team/player partial sums.
Parameters:
filepath: path to the replay filemodule_names: optional list of builtin stats module names. By default all builtin modules are included.frame_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.
See the subtr-actor ndarray docs for the full list of feature-adder names.
Common global features:
BallRigidBodyCurrentTimeSecondsRemaining
Common player features:
PlayerRigidBodyPlayerBallDistancePlayerBoostPlayerAnyJumpPlayerJumpPlayerDodgeRefreshed
PlayerBoost is exposed in raw replay units (0-255), not 0-100 percent.
Repository-level compile check:
just build-pythonFor an importable local Python environment, use maturin develop from the python/ directory:
cd python
uv sync --group dev
uv run maturin develop
uv run pytestIf you are using the repo flake, nix develop now provides the pinned CPython 3.11 toolchain and Python dev dependencies via uv2nix. Create a writable virtual environment from that interpreter, then install the local extension into it:
nix develop
uv venv /tmp/subtr-actor-venv
source /tmp/subtr-actor-venv/bin/activate
cd python
maturin develop
pytestIf you are not using uv or Nix, install maturin, pytest, and numpy in a virtual environment and run maturin develop directly.
This binding depends on the workspace crate via:
[dependencies.subtr-actor]
path = ".."
version = "0.12.0"That keeps local development wired to the workspace crate while still pinning the published dependency version. Use just bump <version> to update the workspace and binding versions together.
MIT