# How it works

The following is a description of how the program processes a single job:

- The program takes your original demo, e.g. “C:\Nexuiz\data\demos\test.dem” and creates a copy of it, the cut demo. This file has the name <original_demo_name>_autocut.dem. The cut demo is different to the original demo in a way that console commands have been injected, so basically the engine thinks that you had entered them yourself (e.g. cl_capturevideo 1 to start recording).

  - Since it is possible to inject any possible console command, the first command that is injected is to disable rendering (r_render 0), save the value of your “volume” setting and then setting it to 0 (as long as you have sound and rendering disabled while fast-forwarding in the preferences of the Demo Recorder). Then a slowmo 100 command (first stage value from the Demo Recorder preferences) is injected in order to fast-forward the demo.

  - Then, when the game time in the demo is about 1 minute less than your specified start time of the job, slowmo is reduced to 10 (second stage value from the preferences)

  - Then, when the game time in the demo is about 5 seconds less than your specified start time, slowmo is set to 1, rendering and sound is enabled again, and whatever your put into the exec before capture field is being injected, too. Then, the values of cl_capturevideo_nameformat and _number are being saved to a temporary variable and are overwritten with defined values (autorec and 1234567), so that the Nexuiz Demo Recorder will know the exact name of the output file (which is necessary so that it can move that file to your desired video destination/location)

  - When the the start time is reached, cl_capturevideo 1 is injected, once the end time is reached, cl_capturevideo 0 is injected.

  - Shortly after, whatever you put into the exec after capture field is executed, and then the original values of cl_capturevideo_nameformat and _number are being restored.

  - Then a disconnect command is injected

- Next, your specified Nexuiz engine binary is launched. The parameters given to the binary are:

  - The content of the engine parameters field of the job, and

  - -demo <relative-demo-path>/<demo-file-name> (this will start Nexuiz, e.g. -demo demos/test.dem, launch the test.dem demo, and the engine will play the complete demo until a disconnect is issued (which we have injected above), and then Nexuiz will close automatically. This -demo parameter exists since Nexuiz 1.0

- Once the Nexuiz Demo Recorder notices that your Nexuiz engine binary closed, it will look for the recorded video file in <DPVideo-directory>/autorec1234567.<avi/ogv> and move it (rename it) to your desired <video-destination>, keeping the original extension of the file. In case the preferences are setup to not overwrite an existing video file, a file with ending _copy1 (2, 3, …) will be created.