Skip to content

Demo files

Saul Rennison edited this page Feb 12, 2022 · 2 revisions

Demo files are created by the game engine. A VCR metaphor is typically used when referring to demos - they are recorded and subsequently can be played back. They can either be recorded by a connected player (known as point of view/POV demos), or by the game server itself (known as GOTV demos). Demo files can be thought of as a log of all of the network packets sent from the game server to the connected players (and vice versa).

POV demos only contain data from the perspective of the recording player. When playing the demo back, you cannot swap to another player's perspective, or 'free roam' around the game world. On the other hand, GOTV demos contain data about the entire game world. When playing these demos, you can freely swap to another player's perspective or fly around the game world to watch the action from any angle.

POV demo files contain all of the network packets that were sent by the server to the recording player. This data is limited to changes in the game world that occur in the player's potentially visible set (PVS). This means that changes that happen on the other side of the game world are not contained in POV demos. Similarly, all of the player's inputs (such as which keys they were pressing, and the movement of their mouse) that were sent to the server are contained in the demo.

GOTV demos contain network packets that represent changes anywhere in the game world. If a tree falls down but there is no player around to see it, it will still be recorded in a GOTV demo.

In most Source engine games demo files are encoded in a proprietary binary format. (In Dota 2, demo files are encoded in Protobuf - see Dota 2 Demo Format.) As demo files mainly consist of network packets, they are very space efficient. The messages have been carefully crafted by the game developers to pack the data as tightly as possible. The format is largely undocumented, the most complete official source being Valve's own demoinfogo tool. Broadly speaking, a network packet can consist of:

  • Game events. These are events that are broadcast to all players, mainly for displaying information on the HUD. Examples include when a player dies or when the bomb is planted.
  • User messages. These serve a similar purpose to game events, but instead of being broadcast can be sent to just a subset of players. For example, chat messages can be sent to all players, or only to some players for team chat.
  • Entity changes. For example, when a player moves or buys a weapon.
  • Sounds. For example, player footsteps or grenade explosions.
  • User commands (POV demos only). Contains information about the player's inputs: which keys are pressed and any movement of the mouse.
  • Other engine messages, for example string table changes.
Clone this wiki locally