Skip to content

Commit 54770b2

Browse files
committed
Add docs for extract_scfa to README
1 parent a25c62b commit 54770b2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,32 @@ done on replay `8653680` (an almost 50 minute long Seton's game).
9696

9797
In this case `body_ticks` turned out to be more than 7x faster than using a
9898
`Parser`.
99+
100+
### Reading .fafreplay files
101+
Replays downloaded from [faforever.com](https://faforever.com) use a compressed
102+
data format to reduce the size of the files. These can be decompressed to the
103+
original `.scfareplay` data using the `extract_scfa` function.
104+
105+
```python
106+
from fafreplay import extract_scfa
107+
108+
109+
with open("12345.scfareplay", "rb") as f:
110+
scfa_data = f.read()
111+
112+
with open("12345.fafreplay", "rb") as f:
113+
faf_data = extract_scfa(f)
114+
115+
# The extracted data is in the .scfareplay format
116+
assert faf_data == scfa_data
117+
```
118+
119+
Note that there are several versions of the `.fafreplay` format. Version 1 uses
120+
base64 and zlib compression which are both part of the python standard library.
121+
However, version 2 uses `zstd` which must be installed through a third party
122+
package. To ensure that this dependency is installed you can use the `faf` extra
123+
when installing the parser:
124+
125+
```
126+
pip install "faf-replay-parser[faf]"
127+
```

0 commit comments

Comments
 (0)