GoldSrc Video Creation

From SourceRuns
Jump to: navigation, search

Once you've recorded your demo(s), it's likely you'll want to turn it into a video to share with others. Here's different ways to do that:

General guidelines

Playback

Videos may be captured using playdemo or viewdemo. The playdemo command is more reliable and accurate in its playback. It is also slightly more convenient to use playdemo for HLAE capturing, thanks to the mirv_movie_playdemostop setting. If enabled, HLAE will stop capturing after playdemo ends. One downside of playdemo is that it disconnects you at the end, causing abrupt cuts to the audio. This can be bypassed with help of another HLAE setting, mirv_movie_sound_extra. When set to a certain value, measured in seconds, HLAE will continue recording the audio for that duration after the end of the demo.

In contrast, viewdemo does not disconnect you at the end. It is therefore useful for capturing sound which continues to play after playback. Unfortunately, viewdemo is less precise as it occasionally does not play all sound. It also does not work across map transitions.

Resolution

Today, it is most sensible to capture videos with a 16:9 aspect ratio and in at least 720p. A case can be made for rendering only in 720p and not higher resolutions, as Half-Life itself has dated graphics and the boost from higher resolution does not contribute much to the perceived quality. While this reasoning is sensible, keep in mind that higher DPI displays have started to gain prominence on laptops and desktop monitors, popularised by the Retina MacBook Pros since 2011. On these screens, higher resolutions can make a difference. If disk space permits, capturing in 4K is recommended though usually not expected. 4K is good for viewing on larger high DPI monitors.

One problem with high resolutions is that the HUD elements look small. If this is undesirable, the solution is to capture the HUD at a lower resolution with the same aspect ratio and scale it up. For example, if the target resolution is 1920x1080, then you may capture the HUD at 1120x630.

Frame rate

Videos should be captured at 60 fps and above. If a lower frame rate must be chosen, then it is strongly recommended that you enable motion blur in one way or another. Otherwise, the resulting video will look jittery. Videos captured at 30 fps in real life do not look jittery because a camera frame is essentially a series of images blended into one. However, a frame in Half-Life is a snapshot at a very specific point in time.

Motion blur can be enabled in many ways. If you are capturing footage using HLAE, motion blur can be enabled by mirv_sample_enable 1. In the context of HLAE, motion blur is sometimes referred to as "sampling" or "resampling". The amount of blur may be controlled by mirv_sample_sps. Contrary to the official recommendation, you may start with a value of about two times the frame rate. Excessive sample rates will result in a very blurry and distractingly amateurish video. This is unless you intend to create a high stylised video, possibly for the end credits.

Higher frame rates may be desirable for viewing on high refresh rate monitors. They are also useful for playback at lower speeds for fast paced speedruns. For these speedruns many details will be missed when viewed at normal speed. A usual frame rate for these purposes is 120 fps. Occasionally 144 fps is also used for 144 Hz monitors.

Special note must be taken when capturing demos created by TASing. For reasons yet unknown, if the capturing frame rate is too low, the viewmodel may bob haphazardly or even fly out of the screen. This issue is usually resolved by capturing at, say, 120 fps.

Field of view

The default field of view (FOV) value for Half-Life is 90, controlled by default_fov. This value is unsuitable for 16:9 aspect ratio videos. Objects look too close and too few of a scene fits the screen. We recommend values around 110. Do not set it too high or the video will look unnatural.

Audio across map transitions

When playdemo is used, the in-game sound will often be cut off at the end of a segment. The standard way to fix this issue is to use the mirv_movie_sound_extra setting. If you’re moving very quickly away from the sound source, you may need to apply a fade out effect to the sound when editing. The sound should fade out quickly or risk sounding unrealistic in the context of the game.

Another way of fixing the issue is by capturing the sound using viewdemo for playback. Unfortunately, viewdemo is not perfect. Certain sound will occasionally be missing. To rectify this you can sometimes simply replace that part of the sound with the part recorded from playdemo. If this is not enough, you can identify the missing sound with the help of s_show 1. Then, try to isolate and record the sound in-game, potentially in different maps. Ensure that the correct room_type is set if you do not wish to disable room effects by room_off 1.

The change level delay trick involves delaying a transition so that the player appears in a strategic location in the new map. At first sight, it appears to have no difference from a normal transition as far as editing is concerned. However, note that sometimes the scene can change drastically in the new location. The player might get teleported to a completely different location in the new map with an environment of different look and feel. In such cases, consider using your artistic licence to deliberately cut off the sound in the previous map.

Even if the new environment is a continuation of the previous map, it may not make logical sense for certain sound from the previous map to continue playing after the transition. To take a contrived example, suppose a transition that is supposed to trigger only after killing a particular monster. After triggering, a building will turn into ruins as a result of the monster's death. Now, a glitch has been found so that this transition can be triggered without killing the monster. Then, if the transition occurs while the monster is making a roaring sound, which is not supposed to happen in the designer's mind, it makes little sense to allow the sound to continue playing in the next map, because the monster is supposed to be dead! The viewers will experience a cognitive dissonance as they witness a building turning into ruins and yet still hearing the monster's roar as though the monster is alive. You can see that it is perhaps more sensible to cut off the roaring sound to make an artistic point about the level of exploitation you have accomplished for the speedrun.

Gauss fastfire and quick weapon switch

In newer Half-Life versions, a weapon's firing sound will be abruptly cut off as soon as another weapon fires. This implies most of the weapons in a series of quick switches should not have audible firing sound, because the sound for each weapon may only last for a frame or two before it got cut off. However, this can cause confusion to the viewer. You may again use your artistic licence to allow the sounds for all weapons to continue playing even if they overlap as a result. In doing so, the viewer will understand that several weapons are being fired in quick succession. This is also applicable for the gauss fastfire trick.

Half-Life Advanced Effects

Probably the best way to capture your demos in HL1 is using an application Half-Life Advanced Effects. HLAE, is a collection of tools to enrich GoldSrc (Half-Life 1, Counter-Strike 1.6, Team Fortress Classic, Day of Defeat..) engine based movie making. You can apply various effects to the frames while capturing demos. Here's how you capture your demos with it:

HLAE, Configured to run the mod "hlspbunny" at the 1280x720 resolution
  1. Get HLAE from the link above and unpack the archive
  2. Launch HLAE.exe
  3. Go to File>Launch, a window to configure settings will appear.
    • If your demos were recorded using a mod (e.g. HLSP BunnyMod or Adrenaline Gamer), in the 'Modification' section choose Other modification: and write the folder name of the mod (e.g. hlspbunny, ag, decay and so on..).
  4. Once you're done configuring, click the Launch button to start Half-Life.

In-Game configuration

Once you launch Half-Life (or your mod) using HLAE, follow these steps to capture the demos. Before recording, you need to set the framerate, post-processing effects and other options using console commands:

  • mirv_movie_filename - sets the location of recorded files (e.g. mirv_movie_filename C:\HLAE\hlstuff)
  • mirv_movie_fps - sets the framerate (e.g. mirv_movie_fps 60)
Higher framerate may take more hard drive space, use the File Size calculator (Go to Tools>Calculators>File Size) to calculate the space needed for your demo(s).
  • mirv_movie_bmp - set to 1 if you want to use BMP instead of TGA
  • mirv_movie_export_sound - set to 1 if you want to export a WAV sound file of your demo.
  • mirv_sample_enable - set to 1 if you want HLAE to add sampling to your frames (motion blur).
Capturing demos with sampling enabled will highly increase the capturing time.
  • mirv_sample_sps - samples per second. Bigger value will increase the strength of motion blur.
  • mirv_fx_wh_enable - set to 1 if you want to render walls as transparent (wallhack).

These commands are essential, and some of them are required to capture demos. For a list of all commands available, see a list of HLAE commands.

Capturing

Now let's get to capturing. Once you're all set with the commands, you'll need additional two commands to start and stop the capturing:

  • mirv_recordmovie_start - starts capturing the demo
  • mirv_recordmovie_stop - stops capturing the demo.

I suggest you to bind these to your mouse buttons, so you can quickly start the recording once the demo starts playing, and stop it when needed. Alternatively, if you intend to capture the full demo using playdemo, simply set

mirv_movie_playdemostop 1

and issue

mirv_recordmovie_start; playdemo demoname

in the console. This starts the capture as soon as the demo starts playing. There is no mirv_movie_viewdemostop, however. If you are using viewdemo and you intend to start capturing right from the start, you can still issue mirv_recordmovie_start; viewdemo demoname similar to the method for playdemo, but stop the capture with the mouse button bound to mirv_recordmovie_stop.

After you stop recording, head to the directory where your demos are recorded (in this case it's C:\HLAE\hlstuff). Here you will find folders named "take%number%" and numerous TGA files named %videoname%%framenumber%.tga inside together with a Wave file named sound.wav. Now you need to take these frames and the audio and turn them into a complete video, using the external video creation application of your choice.

Capturing HUD

Traditionally, the HUD is captured as an inseparable part of the footage. While the HUD visibility can be toggled by hud_draw and crosshair, it was difficult to capture only the HUD itself. This is crucial for fixing HUD glitches during demo playbacks. Fortunately, newer versions of HLAE allow capturing only the HUD using mirv_movie_separate_hud 1. This will produce a game footage with the HUD removed, a HUD alpha footage against a black background and a HUD colour footage. If the alpha footage is all white, you need to tick the "Force 8 bit alpha channel" in the HLAE launch box.

To blend the layers together correctly, you should have

  • top layer: HUD colour footage, blended with linear dodge or add mode
  • middle layer: HUD alpha footage, with colours inverted and then blended with multiply mode
  • bottom layer: game footage

For complex segmented speedruns, you may want to always capture the HUD separately, because after a segment

  • the ammo indicator is often nonsensical unless the demos were recorded using special mods
  • the pick-up indicators disappear
  • the chapter titles disappear
  • the flash light indicator may change abruptly
  • the indicators opacity changes abruptly

One way to fix nonsensical ammo indicators is the following. Start a game in HLAE (ignoring the warning as we’re still in single player) and manipulate it so that the screen contains the correct HUD elements. For example, to fix an incorrect glock ammo indicator, you could run sv_cheats 1; map crossfire; impulse 101 and switch to glock, fire a few shots until you obtain the ammo indicator you wanted. Then, blend the captured HUD with the speedrun footage. To fix abrupt disappearance or opacity changes, you could use viewdemo to continue capturing the HUD after playback.

As a side note, you can consider increasing the opacity for all elements throughout the run. This is because the default opacity is rather low, making the elements difficult to see. Remember that watching the HUD indicators is part of enjoying a speedrun movie. You can capture the demos in a mod that allows adjustments to the HUD. Alternatively, you can increase the opacity when editing. Usually, you want to use the video effect which alters the hue/saturation/value of the HUD clip and increase the "value" parameter for that effect.

As mentioned previously, at higher resolutions the HUD elements will look tiny. You may or may not find this desirable. One way to fix this is to capture the HUD at a lower resolution. Then, scale the footage up to match the target size. Consider using the bilinear algorithm over other scaling algorithms, as it is faster and we do not want the fuzzy/burry edges usually resulted from them. In FFmpeg, this can be selected by adding the -sws_flags bilinear flag.

Capturing viewmodel

The term viewmodel refers to the model comprising of the player’s weapon and hand that is hovering at the lower left or right corner of the screen. The viewmodel occasionally animates, and thus is subject to abrupt cuts when segmenting. In addition, if playdemo is used for demo playback, the viewmodel may mysteriously disappear for one frame at the very beginning. The approach for fixing these issues is similar to that for the HUD, that is to capture the viewmodel separately. To do this, adjust these settings prior to the capture:

mirv_movie_splitstreams 3
mirv_matte_setcolor 0 255 0
mirv_matte_entities add 1

HLAE will create a normal game footage without the viewmodel and a separate footage containing the viewmodel against a green screen. You can also specify mirv_movie_splitstreams 2 to capture only the viewmodel and not the game footage.

To fix the issue of the viewmodel disappearing for one frame, simply take one adjacent frame and place it on the frame with missing viewmodel. On the other hand, to fix the issue of the viewmodel's animation stopping abruptly, capture the entire viewmodel animation by playing the demo with viewdemo. Use this footage to replace part of the next segment's footage which contains the non-animating viewmodel.

Exporting frames to a video

If you are a Windows user, the easiest way to export your recorded demos to a video is using the VirtualDub application.

  1. Open VirtualDub, then go to File>Open. Browse to your specified directory with the recorded frames
  2. Select the first frame of a specific demo, and VirtualDub will automatically import the following.
  3. Go to Audio>Audio from other file.. and choose the WAV file created along with the frames.
  4. Go to Video>Compression and select your preferred codec.
  5. Go to Video>Frame rate and select the option for the frames to match audio length.
  6. After you set everything up, go to File>Save AVI... and choose a save path. When you click OK, VirtualDub will process the TGAs into an AVI file.

Alternatively, you can use the extremely versatile cross-platform tool called FFmpeg. For most of the time, inside the directory containing the captured frames, you need to issue only one command which looks like this:

ffmpeg -r FPS -i %05d.bmp -c:v CODEC OUTPUT

Here, replace FPS by the capturing frame rate, CODEC by the codec name and OUTPUT by the output file name. A list of codec name can be generated by ffmpeg -codecs. The container format will be automatically detected using the extension you specified for OUTPUT. For example, if OUTPUT is out.mkv then the container format will be MKV. If OUTPUT is wr_seg.mov then it will be the QuickTime file format.

Linux video editors such as Kdenlive accept many codecs. Consider using the huffyuv codec as it supports RGB and is lossless if you intend to import the frames into one of these editors. On the other hand, Final Cut Pro X supports the Apple ProRes codec the best. In this case, use the faster prores codec for game footage and prores_ks for viewmodel and HUD footage. The rationale for prores_ks for the latter two is that it encodes to ProRes 4444 by default which preserves the colours better. If you do not want to edit the footage and intend to encode it for distribution, simply specify libx264 for CODEC and add the appropriate options for the codec.

To resize the HUD footage, simply add -s WIDTHxHEIGHT -sws_flags bilinear before OUTPUT. For example,

ffmpeg -r 120 -i %05d.bmp -c:v huffyuv -s 1920x1080 -sws_flags bilinear wr_take1.mkv

Adobe Premiere

  1. Start a new project and set the project settings to match those you recorded the video in (frame size, pixel ratio, framerate).
  2. Import the audio (File->Import... and browse for sound.wav).
  3. Import the set of frames by selecting the first frame of the video (%videoname%0000.tga) in the same Import window, and checking the "Numbered Stills" checkbox.
  4. Drag the set of frames and the audio onto your timeline, and line them up at zero.
  5. Select File->Export->Movie... to save out your video. Remember to check and tweak the codec settings to get a balance between quality and filesize that you are happy with.

Sony Vegas

  1. Open Sony Vegas, then go to File>Properties to set up your project-settings. These should be matching your frames you extracted. Field order should be None (progressive scan) and Deinterlace mode should be None. Click OK.
  2. Now go to File>Import>Media and to the folder with your captured frames.
  3. Select the first frame, such as %videoname%_0000.tga. Vegas will take a moment to scan all the frames it can find. Make sure Open still image sequence is checked, and the number of frames is correct in the textbox of range.
  4. Click Open.
  5. A new window called Properties will show up. You can make some settings on your new clip, but leaving everything on default will doing fine.
  6. Click OK to close the Properties window.
  7. You now have a new clip in your Project Media window. Drag'n'drop the new clip into your timeline. Now you can start editing it like a usual movieclip.
  8. To add your soundfile, go to the Explorer window, and find your sound.wav file. Drag'n'drop your soundfile to your timeline, like you did it with your videoclip.
  9. To render your movie, go to File>Render As....

Fraps

Another way to capture something is to use a widely-known application Fraps. Fraps won't provide you with the post-processing tools, and might even cause some FPS Drops during recording, but it's the fastest and the easiest way to record your demos. Another downside is that the free version of this application will place a watermark on top of the video, and will limit your video length up to 30 seconds. It's not recommended to record speedruns using this tool, and it should only be used to capture a short clip for YouTube.

  1. Load up Fraps, configure it and minimize it.
  2. Launch Half-Life. You should see a yellow FPS counter at the corner of your game.
  3. Start a demo playback and hit F9 (default key) to start recording with Fraps.
  4. The FPS counter should turn to red, indicating that it's recording.
  5. To stop recording, simply hit F9 again.
  6. Your movie will be stored in C:\Fraps\Movies by default.

See Also

Personal tools