Difference between revisions of "Demo"

From P2SR Wiki

Line 83: Line 83:
 
====Binds====
 
====Binds====
 
* Start Render bind: <code>startmovie <renderpath>; demo_resume</code> (replace <renderpath> with the path to the raw frames folder you made)
 
* Start Render bind: <code>startmovie <renderpath>; demo_resume</code> (replace <renderpath> with the path to the raw frames folder you made)
 +
<pre style="color: red">Important: In the render bind you need to name the images aswell.</pre>
 
* Optional "tick 1" bind: <code>sv_alternateticks 0; demo_pauseatservertick 1; demo_resume</code>
 
* Optional "tick 1" bind: <code>sv_alternateticks 0; demo_pauseatservertick 1; demo_resume</code>
  

Revision as of 15:38, 21 January 2021

Demos


Overview

1280px-Source engine logo and wordmark.svg.png

Demo files are used in Portal 2 as a form of proof for runs, and a way to carefully analyze a segment of the game.

For More information on the .dem file format visit the Valve Developer Wiki

How to Record a Demo

In the developer console, type record demoname, where demoname is the name of your desired demo file.

The demo files are stored by default in your portal2 folder (SteamLibrary\steamapps\common\Portal 2\portal2)

Demo Playback

Demos can be played back in game for viewing, or for external recording with playdemo demoname where demoname is the name of the demo file you recorded to. Use stopdemo to stop demo playback. startdemos plays a sequence of demos (for example: demo, demo_1, demo_2, etc).

SAR has and improved version of the startdemos commands for demo viewing.

  • sar_startdemos
  • sar_stopdemos - Stops the demo queue.

You can use the command demoui for more options while watching demos, or you can use shift + F2.

Stopping Demo Recording For Single Player Challenge Mode

If a demo recording is not stopped in Single Player Challange Mode, the timer will become inaccurate up to .4 seconds. Meaning when you carry over demo recordings, your times in single player cm could be .4 slower than they would have otherwise been. This does not impact coop Challenge Mode.

To stop demos, simply use the stop command. This can be bound to your restart level key. bind key "stop;restart_level". The reload command will also stop demo records, and restart your level in Single Player Challenge Mode, however it is worth noting that the command will load from a save point in full game, and not work at all for coop Challenge mode.

Saving Demos to a Subfolder

You can save demos to a subfolder by naming the file with a pre-existing folder name, followed by a backslash, and the demo name.

  • NOTE: If the folder does not exist, Portal 2 will not create a folder for you and your demos will not be recorded.

(Ex: record foldername\demoname)

Easy Recording Methods

If you aren't using SAR to handle demo recording, the most common way to record demos easily in Challenge Mode is to bind it to your w key along with +forward. For example, bind w "+forward;record demo"

Challenge Mode

Challenge Mode Demo Tutorial

SAR Demo Recording Tools

SAR has many useful features for demo recording. Particularly during full game runs. These features are mention on the jerrypedia page for SAR.

Blenderiste09's fork of SAR (linked on the SAR Jerrypedia page) includes the commands

  • sar_record_at_demo_name
  • sar_record_at (default value 0)
  • sar_record_at_increment (default value 0)
Note: sar_record_at does not work for the orange bot in coop.

sar_record_at_demo_name takes a value for the name of the demo the functions will record. Example: sar_record_at_demo_name demoname.

sar_record_at has a default of 0, which will not record a demo, but any value higher is the number of ticks in game that will go by before a record starts. For example, to start on the second in-game tick: sar_record_at 2.

Note: If you pause the game with the esc key on the frame that the demo is set to record, the recording will not be processed. Preforming a console pause (pausing by opening the console with ~, the pause will not interrupt the recording.

sar_record_at_increment will add a number after your demoname (Example: demoname_2) if set to 1. This acts as version control, to avoid overriding demos you might have wanted to revisit, but does stack up new demos until the game is restarted, so if you use this feature, it's a good idea to periodically delete demos.

Demo Rendering

gaming's guide on demo rendering

Frameblending

Good settings for SrcDemo²

This is what the settings from above should look like. Video by Swagatron, rendered by gaming

Software needed for frameblending


Setup

Folders

  • Make 2 folders in the Portal 2 folder, one for the raw frames and one for the blended frames and then set the paths for them in SrcDemo².

Binds

  • Start Render bind: startmovie <renderpath>; demo_resume (replace <renderpath> with the path to the raw frames folder you made)
Important: In the render bind you need to name the images aswell.
  • Optional "tick 1" bind: sv_alternateticks 0; demo_pauseatservertick 1; demo_resume


Frameblending the demo

So first, you are going to launch SrcDemo². Now you can mess with some settings. Set host_framerate to whatever number SrcDemo² displays and press "Activate". Play your demo, go to tick 0 and pause. Then you need to get on tick 1 by inputting these commands:

  • sv_alternateticks 0
  • demo_pauseonservertick 1
  • demo_resume
Note: I recommend binding these 3 commands to a key for ease. See the bind above.

Now you have to set sv_alternateticks back to 1.

Note: Don't bind this 4th command in the same bind as the other 3.

If you did this part correctly, when you open demoui (open by pressing Shift+F2 or by typing demoui in console), it should show that you are on tick 1. Now press your start render bind and wait until it finishes. Once it finishes type endmovie in console. Now just put all the frames together in some editing program.