Next Previous Contents

4. DEMcut, The DEM file cutter tool

4.1 Introduction

DEMcut is the DEM file cutter tool. I don't know anything about movie cutting whatsoever but DEMcut should help you a lot cutting parts out of a DEM file, putting different DEM files together or using some special effects like slow-motion or backward moving of particular scenes.

DEMcut does all this and much more in a very easy way: It gets the names of all DEM files to be processed from the command line and reads from ``Standard In'' commands to manipulate them. During the manipulation DEMcut writes one or more DEM files.

A good knowledge of DEM files is required to use DEMcut. DEMcut doesn't do any checks to prevent you from creating non-working files.

4.2 Batch usage

The easiest way to use DEMcut is with a cutting list batch file. This file should contain all commands to be processed and can even have some comments why you did something like you did it. Use any text editor for this and start DEMcut with an input redirection.

demcut demfile1.dem demfile2.dem < commands.txt
DEMcut starts, reads in all DEM files from the command line and reads the commands from the command file. All messages (every command produces a message after completion) from DEMcut go to the screen or may be redirected to a logging file as well.
demcut demfile1.dem demfile2.dem < commands.txt > output.log

4.3 Interactive usage

One of the best feature of DEMcut is the possibility to do an interactive analysis of DEM files. The interactive mode is not compiled in on systems without support for named pipes. It runs with Unix and Linux but not on MS-DOS, Win32 etc.

I will describe now the Linux use. First you have to create a named pipe in the directory where your Quake copy reads its DEM files from.

mkfifo fifo.dem
Now start Quake (make sure to use xquake and and not xf86quake) in a window as usual and playdemo this named pipe.
playdemo fifo
Quake tries now to read a demo out of fifo.dem but there is nothing to read in: it stops.

Now comes the appearance of DEMcut. Open a new window and start DEMcut with the DEM file of your interest.

demcut mydem.dem
DEMcut reads in mydem.dem, does some preprocessing and waits for input. The first thing to do is to direct all output to the named pipe.
o fifo.dem
Now create the start of a normal DEM file with CD track and level initialisation.
c -1\n
r 0 2
It's unbelievable but Quake starts now the level and waits for further actions. Now play around with different ranges, speed tests or backward movements. Don't forget to put the disconnect frame at the end. Quake will usually play immediately what you intend but the Quake client time stands still after playing, so all the active sound patches will be repeated over and over and the Quake doesn't redraw its window.

This is the point where the ``interactive mode'' comes in: DEMcut changes its behaviour with the command

i 1
This repeats the last frame sent to Quake but with an ongoing time. The interactive mode allows you to type in new commands during a range command.

Now you can fast forward wind and rewind to find out all the frame numbers of interest. In another window you can now edit your cutting list batch file and run this file for cutting the final product.

4.4 Commands

There are not too many commands but they are very powerful. The command language is line oriented: one line means one command. Comments start with `#', empty lines or lines with wrong commands will be ignored as well. DEMcut prints a short response after finishing a command to stdout.

Help

Syntax:

h

Description:

DEMcut prints a very short online help. If `i' (interactive mode) isn't listed, your operating system doesn't support named pipes and the interactive mode is left out.

Output file

Syntax:

o filename

Description:

Writes further output to this file. The old output file (if there was one) will be closed. If the output file can't be written (permission denied), DEMcut bombs back to the OS shell without any warning. I may do a check in the future.

Query syntax:

o

Description:

Prints the current output file name.

Default value:

demcut.dem

DEM file

Syntax:

d filename

Description

Selects this DEM file as source.

Query syntax:

d

Description:

Prints the current input DEM file name.

Value range:

Any DEM file name. DEMcut generates an error, if the file is not a good DEM file.

Default value:

First DEM file from the command line. If there was no valid DEM file on the command line the d query command generates an error.

Speed

Syntax:

s speed

Description:

Speeds up all further output by this factor. speed>1 increases the play-back speed, speed<1 slows the play-back down.

Value range:

speed may be any positive float value.

Query syntax:

s

Description:

Prints the current speed.

Default value:

1.0

Time

Syntax:

t time

Description:

Sets the current time.

Value range:

time may be any positive float value.

Query syntax:

t

Description:

Prints the current time.

Default value:

0.0

Loop

Syntax:

l loop-count

Description:

Sets the loop count. Every further frame will be written loop-count times to the output. The time goes forward as usual.

Value range:

loop-count may be any positive integer value.

Query syntax:

l

Description:

Prints the current loop count.

Default value:

1

CD track

Syntax:

c track

Description:

Write the CD track string to the current output. If the CD track string doesn't end with whitespace (`\t', `\r', `\n', `\f'), an `\n' will be silently appended. Don't forget this command at the beginning of every DEM file (like it happened with finesc5.dem of the Eschaton movie).

Query syntax

c

Description:

Prints the current CD track string.

Default value:

-1\n

Frame

Syntax:

f frame-number

Description:

Writes the selected frame to the output. This frame gets the current time. The time will be increased afterwards by the frame duration divided by the current speed. The whole process will be repeated as much as the current loop count states.

The frame command stops in interactive mode a running range command.

Value range:

frame-number can be any integer number between 0 and the maximum frame number in the currently selected DEM input file.

Query syntax:

f

Description:

Prints the current frame number.

Default value:

0

Range

Syntax:

r range-start range-end

Description:

Writes the selected range of frames to the output. Every frame gets the current time. The time will be increased after each frame by the frame duration divided by the current speed. Every frame will be repeated as much as the current loop count states. In interactive mode you can use any commands during a running range command (i.e. speed change). The range command can be stopped in interactive mode by a new range command or a frame command.

Value Range:

range-start and range-end may be any integer number between 0 and the maximum frame number in the currently selected DEM input file. range-end may even be smaller than range-start. If they are equal the result is the same as with the frame command.

Query syntax:

r

Description:

Prints the current range.

Default value:

0, last frame number of the first DEM file from the command line.

Multi-player preparing

Syntax:

m multi-start multi-end

Description:

Grabs out of the defined frame range all updatename and updatecolors messages and writes all these messages together with the camera angles of the last written frame to the output. It doesn't write anything if there was no updatename or updatecolors message in the defined frame range.

Everyone, who ever tried to concatenate different multi-player DEM files knows the problem: The ``actors'' log in to the server in a different order and so they get every time different player numbers. If one tries to assemble all these files together one will end up with the wrong colour scheme because all players stick to the colour, number and name from the very first recording. The only solution is to insert the right name and colour definition of each part in the final product. And this does the ``m'' command.

Value Range:

multi-start and multi-end may be any integer number between 0 and the maximum frame number in the currently selected DEM input file. multi-end may even be smaller than multi-start.

Query syntax:

m

Description:

Prints the current multi-player range.

Default value:

0, last frame number of the first DEM file from the command line.

Interactive mode

Syntax:

i inter

Description:

Toggles the interactive mode. The frame and the range command will be affected by the interactive mode. This command is not implemented on all systems. Use the help command (`h') to find it out.

DEMcut continues to write (under certain conditions) the last written frame with an ongoing time. This feature is useful for an interactive use only (as the command name suggests). DEMcut remembers the (real) time, when the last frame written to Quake is finished. If up to this time came no new command (this is the normal case in interactive use) and the interactive mode is on, DEMcut writes the last frame again. But the time stamp of this frame goes on and on. So Quake gets always new frames and doesn't stop. This is extremely important for users with many overlapping windows (like me): Quake refreshes its window in an normal working state only. It is very interesting to see what happens in the Quake window, if it gets always the same frame but the time goes on. This shows us the different sources of movement: particles (blood traces) are totally moved by the client (they continue to move ), gibs are frozen in the air (they are real entities) and the weapon moves up and down as usual (client driven). DEMcut does not allow to repeat frames which change the signon number (frame 0, 1 or 2 of a normal DEM file). Neither does it repeat the disconnect frame.

The range command may be interrupted by other commands. You need this for looking at the current frame number (frame command without new frame number), for changing the current playback-speed etc. A new frame or range output command stops the running range command.

Value Range:

0 (interactive mode off) or 1 (interactive mode on).

Query syntax

i

Description:

Prints the current interactive mode.

Default value:

0

Quit

Syntax:

q

Description:

Closes the output file and quits DEMcut.

4.5 Example

A very easy task is to create a DEM file, which shows with double speed the reversed actions of the well-known demo ``Ranger Gone Bad ][: The Assault'' (created by United Rangers Films).

To do this start DEMcut with

demcut rgb2.dem
and type in (or much simpler use a text file and redirection)

# this is a comment, I love comments
# select the output
o rgb2rev.dem
# select the input (not really necessary)
d rgb2.dem
# speed things up
s 2
# write the CD track
c -1\n
# write the starting frames (level init is in 0,1 and 2)
r 0 2
# write all frames in reversed order (actions are in 3..7330)
r 7330 3
# write the disconnect frame (is the last one)
f 7331
# quit
q

This creates the new DEM file rgb2rev.dem with the desired content.

4.6 Problems, ideas and everything

The current implementation of DEMcut is full of deficiencies but anyway, it works.


Next Previous Contents