SwitchBlade is a command-line tool allowing you to create RoQ files (D3 video format) out of AVI's. It looks quite technical and the documentation doesn't provide clear information about how to use it. Because of that, it is mainly aimed at advanced modders willing to integrate video in their mod.





By Eric 'Riot' Lasota - riot AT icculus DOT org

If you have a video that will not work right AND conforms to the notices in the
included IMPORTANT.txt file, please e-mail me so I can work on fixing it.

DropROQ - GUI-based encoder.  You can still set options via the command-line though.
roqcmd - Command-line version of DropROQ.
roqmux - Utility for merging audio into RoQs.
roqplay - Not here any more.


DivX and Indeo Video are both AVIFile-compatible codecs.

By the way, default settings are 16.7:1 compression on keyframes,
50:1 compression on every other frame, and a keyframe every 120 frames,
a.k.a. 4 seconds.

Cross-platform-oholics have source code at their disposal and can write
a video importer on their own platforms if they feel they're being

DropROQ is pretty self-explanitory.  Run it from the command-line for full
customization, or just drop a file on it to compress it in one go.  It
produces 2 files with 2 extensions: One with .RoQ, which is the resulting

video, and one with .cbc, which is the codebook cache, a file used to
accelerate future encodes of the same video.  If you change the video,
then you should delete the .cbc file.

If you run with the -nomux option, then the .RoQ file will be video-only,
and a .wav file will be outputted as well.  You can combine the two with
the ROQMUX program.

RoQ videos are split into two frame types, which I'll refer to as I
frames and P frames since MPEG uses those terms as well.  I frames are
independent, and contain only image data.  Since image data is far less
efficient than motion and skip coding, you should allocate a significantly
higher amount of data to them.  P frames are previous-referencing frames,
and use the previous 2 frames to optimize itself.  P frames use motion
searching and skip testing to minimize their size, and are far more

You can set the I/P frame size relative to the real size by using a
number representing a fraction over 10000, or manually set the bit rates.
Bit limits are PER-FRAME, not per second!!  Framerates are always 30fps,
a limitation of the RoQ format, so just divide your desired BPS by 30 for
per-frame limits.

Unlike SwitchBlade2, version 3 is VERY good with meeting the target
bitrate, will never exceed it (unless it has no choice), and will
generally come within 1% of the target bitrate.

Audio is compressed with 2:1 lossy compression, with 240 bytes per second
added on for markers.  This CAN NOT BE CHANGED, so be sure to adjust your
bitrates accordingly.

avi2roq encodes audio AFTER it encodes all video.  The reason for this is
that RoQ tends to be very picky about sound timing and reading multiple
streams from an AVI file at once is a pain in the ass.  So instead,
avi2roq will automatically dump the sound track of the AVI file to a WAV
file when it finishes encoding the video, then will multiplex the two
files together.  You can prevent multiplexing by using the -nomux
command-line option.

If you want to multiplex later, use the roqmux utility.

Oh yeah, and if it's slow, don't worry, it's not just you.  Like most VQ
encoders, SwitchBlade 3 is SLOW.  It uses a method comparable to the Id
encoder to generate codebooks, so the codebook quality is roughly the
same.  However, ever since version 2, SwitchBlade has used more accurate
quality-detection methods, which nearly double the time of post-codebook
operations, but are needed for proper motion searching and improve
quality anyway.

It is unlikely that SwitchBlade will ever be screaming fast: I
prioritize quality over speed, and even thresholding doesn't give
the encoder a significant boost, so I just left it out.  The only
exception to the rule is the motion searching, which uses an
accelerated algorithm because it is 9 times faster than full search
in the same area, and over 10 times faster than full search in
the entire search area.

Just run it overnight.

There are no comments yet. Be the first!