Playing ROQ Video Files

From The DarkMod Wiki
Revision as of 19:28, 14 March 2020 by Geep (talk | contribs) (revise headers)
Jump to navigationJump to search

Examples: A Repeating Video on an In-Game Laptop; and on Your Own Video Surface

Preamble

Originally written by Drumple on http://forums.thedarkmod.com/topic/3504

These examples, and their recommendations, are by Drumple circa 2007. This was rewritten for concision by Geep, 2020, with these added preamble notes. The general approach is still valid, but the specific tools (SwitchBlade, VirtualDub, and the older Doom3 Editor) are less viable now. Standalone SwitchBlade is no longer available; its development ended with version 3, at which time it was folded into FFmpeg RoQ. TDM now uses a FFmpeg subset for video decoding, including RoQ.

Instead, see two 2015-era tutorials by ZaRR:

  • The first uses XMedia Record to preprocess, then FFmpeg to output RoQ
  • The second uses Shotcut and XnView to preprocess, then roq.exe, id's official win32 RoQ encoder. The latter is evidently no longer available from id, but the tutorial provides a copy.

Other 2020-era comments are shown in [square brackets].

Introduction to the RoQ Format

The ROQ video file format is one traditionally used id Software, starting with early Doom and continuing (with some tightening of playback format requirements) to Doom3. These latter requirements include:

  • a square, powers-of-2 frame format (e.g., 64x64, 128x128, etc.), holding a width compression of the original's standard-definition 4:3 aspect ratio (i.e., width/height = 1.3333)
  • 30 frames per second
  • separate audio file, e.g., OGG format.

Programs to Create a ROQ File

Among possible programs to make ROQ files [ref Riot], some, such as QVM, fail for our purposes because they cannot handle square videos. SwitchBlade 3.12 works well, paired with preprocessing by VirtualDub.

Preprocessing an AVI with VirtualDub

SwitchBlade 3.12 will expect an AVI to have following input format:

  • a square powers-of-2 format. 512x512 is recommended for Doom3 cinematics
  • image width compression from a 1.3333:1 [i.e., 4:3] aspect ratio
  • 30 fps
  • Typically no audio.

Use VirtualDub to achieve these. From SwitchBlade documentation, some considerations:

Audio

Audio can be included in the ROQ, but Doom3 evidently ignores it. [Unknown if this is still necessary true in TDM 2.06+] In the GUIs that use video and audio, the audio is triggered to play from a separate OGG or audio source at the same time the video is started. But if you want to make a ROQ with audio, the source audio must be 22050 Hz, or it will be resampled to that. More typically, in VirtualDub:

  • Export the original AVI's audio track as a WAV file. Later, use your favorite audio software to make it an OGG.
  • While preparing to create the ROQ video, select NO AUDIO from the VirtualDub Audio tab.

Video

  • The 512x512 ROQ video format was used by id in Doom3 for the id logo and some cinematic scenes, such as where you get rescued in the last scene. So those dimensions should generally suffice.
  • Video source dimensions should be at a power of 4:3. So if need be, adjust the video source with VirtualDub (as discussed in the SwitchBlade documentation).
  • Optionally, choose an overall quality compression you want from the compression tab. (Drumple prefers no compression, which makes huge AVI files but has the best image quality.)
  • As needed, use any other VirtualDub filters to improve the quality of the AVI.
  • Finally, save as AVI.

Converting AVI to ROQ with SwitchBlade

Just drag and drop the foregoing preprocessed AVI onto the DropROQ.exe from the switchblade folder... sit back and let it make your ROQ video.

Viewing the Results in a Standalone Player

  • Switchblade 3.12 has no ROQ player to see the final product, but SwitchBlade2 (available from the same site) does.
  • If you have it, Media Player Classic can play most ROQ videos.

Testing the Video and Audio In-Game

On an In-Game Laptop Screen

There are different ways to implement a new ROQ video in-game. Here, we'll use a moveable_laptop, since it has a common/gui surface in the model already, right in front of the screen area.

First, put the ROQ video (myroqtest.roq) and the OGG sound (myroqtest.ogg) into your game's directory, for example, within a folder called /video.

Create a material shader [e.g., within some .mtr file in your materials folder]:

video/myroq
{
   translucent
   {
       videomap "video/myroqtest.roq"
       linear
   }
}

Next, we want a GUI that will -

  • wait 8 seconds, then play the video [assumed to be about 8 seconds long]
  • replay it every 8 seconds after that.

So create a file named myguitest.gui, placed in the /guis folder, with content:

windowDef Desktop
{
   rect 0 ,0 ,640 ,480
   backcolor 0, 0, 0, 1
   matcolor 0, 0, 0, 1
   background "guis/assets/common/bg"

   windowDef VidFrame
   {
       rect 0,0,640,480
       visible 1
       backcolor 1, 1, 1, 0
       windowDef RoqFile
       {
           rect 0,0,640,480
           visible 1
           background "video/myroq"        // ROQ shader defined in the material file
           matcolor 1,1,1,1
           onTime 8000
           {
               resetCinematics;
               resetTime "Anim" "0";
               localsound "video/myroqtest.ogg"; // sound file to accompany the video
           }
       }
   }
}

Then open up the Doom3 editor [or Dark Radiant these days] and the map that you want to test in, and add a moveable_laptop from the menu...

Add a key/value [i.e., spawnarg] of gui /guis/myguitest.gui to it, for the GUI we just made.

Save/bsp and try it out. Here's a screenshot of it working in-game:

Alternative: On Your Own Video Surface

To make a video surface:

  • Make a brush and convert it to a func_static
  • Add the gui key/vals, as above.
  • Select one face - where your video will play - and apply the common/entitygui to it
  • Make sure you fit that image to your selected face [e.g., in DR Texture editor], otherwise the video will play in a corner of the selected face. (In the Doom editor, figure 8 shows fitting the guientity.)

RoQ References

VirtualDub. Development of this ceased at the end of 2013, and its forum expired in 2015, but (as of Feb. 2020) the last stable version is still available for download at VirtualDub.

Quake Video Maker (QVM) - Easy ROQ creator. Historic URL, no longer valid: www.swift-tools.net/Quake/QVM/ . QVM is still available from 3rd-party sites.

Switchblade Video Encoder/RoQ Converter. Last reported version was 3 says planetdoom, pointing to Riot's homepage. No longer.

Doom3world Discussion

Modwiki ROQ

[Riot] At one time there was a list of ROC-creation programs at Riot's House of Stuff.

RoQ Brief history and tech overview at RoQ.

RoQ Encoder Official Encoder (win32): idsoftware ftp

For an alternative take on using QVM to create ROQ files, see How to create a RoQ video-file