:: Introduction ::

:: Game Path ::

Note #0:

Note #1:

:: Preparation ::

VirtualDub (Homepage, v1.8.6 at time of writing)

Xvid Codec (Homepage, Download page, v1.1.3 at time of writing)

:: Recording a Demo in-game ::

:: Encoding Demos ::

:: Processing the video ::

:: Uploading the video ::

:: Advanced - Cyclic Demos ::

So what's this tutorial all about? It's for all those times you've fired up a Source Engine game, done something crazy online and wished you could share the moment with other people in the form of a gameplay video, say on YouTube. Perhaps you've even read Valve's Demo Recording wiki entry or other tutorials, but you're not quite sure what settings to use to make a movie for uploading to YouTube.The goal of this tutorial is to detail the steps I use for Source Engine movie creation. The instructions below were confirmed to work with Team Fortress 2, Left 4 Dead and Counter-strike Source, but other games derived from the Source Engine may work also. The tutorial was the result of research and trial-and-error over several months - and using only free software. The ideal isn't to produce ginormous pixel-perfect videos, but rather movies that are good and small enough to upload onto a video-sharing site (like YouTube) quickly from a home broadband connection to share with friends/strangers.To do this we need to:1. Install some free video processing/encoding software2. Record demos in TF2/L4D/CSS3. Encode the demos as videos4. Process and compress the videos5. Upload to YouTubeAll of this might sound daunting at first, but once you've done it once or twice it becomes a no-brainer and takes relatively little effort.One thing to note is the game path. If you have Steam installed under, you'll have to locate and remember one of the following paths depending on which game you are targetting:... whereis your Steam login name.All paths and files referred to in tutorial will be relative to this respective base path!The remainder of this tutorial will target TF2 but the only difference between other games is the base and file paths used - the commands and methods are identical!We need a couple of things other than the game to get started - a video processing program and a decent video codec:The VirtualDub program comes as a zip file, so you'll need to extract its contents somewhere to use it properly. The Xvid codec has a much easier installer:Once they're installed, we can forget all of this for the moment and come back to it when we're ready to encode a video.If you haven't already done so in the past, enable the. For TF2/CSS, it's under. For L4D, it's underNow bring up the Console with thekey. We'll make a key binding so that every time the forward-slash is pressed, the game will start recording a fresh demo without requiring us to pause mid-game and manually enter commands in the Console. It's great for situations where a firefight is getting hot and you wish to start recording immediately without delay, and without getting killed!Just enter:The syntax should be fairly straightforward: when the forward-slash key is pressed the game first stops any demos that are currently being recorded, then begins recording one called. This means you can hit forward-slash multiple times at different stages of a game to overwrite the same demo file with a fresh recording.What if you wish to be able to keep several demos without overwriting them? You can chose to make several key bindings for different demo names, but it may get difficult to keep track of which you're up to. I prefer using cyclic key bindings to make the game advance through several names automatically but still only using one key. If you wish to cover this, read the cyclic demo howto section at the end of the tutorial, otherwise you can just use the simple method already covered.So go ahead and play the game for a night or two and record some demos. Demo files are relatively small and have virtually no impact on gaming performance, so there's no harm just hitting the forward-slash key every time you join a server. At least you'll know that if you happen to do something crazy later in the game, you'll have a recording of it - instead of wishing you did! Also, demos continue recording through map changes (though a new enumerated demo file will be created). If you quit and join another server though, you'll need to restart recording.At this stage we have a demo that we wish to make a movie out of. Make sure you're not in a server, or just type thecommand in the Console to make sure you're not recording.: Now set the resolution to 640x480, with "Run in a window" enabled.Why? We need to use a lower resolution that's suitable for movie making, as a regular high resolution will take a very long time to make and use up a huge amount of disk-space. I recommend 640x480 as it is a multiple of what's usually uploaded to YouTube and will scale nicely, plus the HUD and icons will be a good size. If you chose 320x240, the HUD may take up most of the screen!: YouTube recently added widescreen support, so you can experiment with widescreen resolutions once you've got the hang of things. For now I'd suggest sticking to 640x480.Now typein the Console to bring up the demo playback interface. Hit thebutton and chose the demo you recorded.Once the demo is loaded, it will play automatically. You can then pause, rewind/fast-forward, speed up and slow down playback. The idea here is to find the section of the demo that you want to make a movie out of. For example you might want to exclude the footage of the warm-up period to avoid boring viewers of the video, or perhaps you did something awesome 35 minutes into the demo. The key here is to note the 'tick' number at the start and conclusion of your action segment (see the DemoUI image above for where this is displayed).Now that you have noted the number, just pause the demo but keep it open. What we'll do now is automate the game to encode the demo for us, as it's much easier than trying to manually hit keys to record at the right time. So clickin DemoUI, thenand selectNow in the new menu, add a descriptive name to the actions (anything will do). In this example we'll assume we're interested in gameplay between ticks 5000 and 8000. Set the start mode to, the tick value to 5000, then add the two commands to be executed at that tick:This will ensure the output movie (as well as the demo) framerate is 60fps, a suitable rate for our purposes. Also ensure there is a space betweenand, asis a parameter and not the file extension! Next hitto save the command, then create a newentry, this time for ending the movie and stopping demo playback in one go. Enter a suitable name again, set, tick value at 8000, and the following commands:Hitand you should see a summary of your entries:Hitagain to return to the demo playback window. Now hitin DemoUI to stop the currently playing demo, and close any windows you have open inside the game (including and especially DemoUI!) to make sure they don't end up showing in the demo.Now what we want to do is fire up the demo about 1000 ticks before our area of interest (ticks 5000-8000), meaning we want to start at tick 4000. This extra time will give the game some time to recover from the fast-forward and fix up any audio and visual glitches that are a result of the fast-forward! Then when it reaches tick 5000, the game will begin encoding the movie, and at tick 8000 it will automatically stop. We now enter the following command into the console to begin playback at tick 4000 of the last played demo:Then sit back until the game reaches the encoding point (tick 5000). The moment this occurs a window will pop up to ask what format you wish to encode the movie. I've found recording straight to Xvid/DivX to be buggy and crash-prone, so just selectThis will result in a very large movie - roughly 50MB per second of video, so a 1GB sized movie is typical. Don't be worried if the demo playback is slow, the sound is distorted or if you have trouble playing back the movie in a video player later, it's normal for an uncompressed video of this size and framerate. The actual encoded movie itself is fine! Now let the automation play out in the game (don't enter the console or anything else!) and wait for the playback/encoding finish by itself. Once this happens we can move onto the next part.We now have a massive uncompressed video located in the base TF2/L4D/CSS path. It should be called. Start VirtualDub and either drag the AVI file onto the program window, or selectand select the video. It should open up showing the first frame:We then configure the compression via. Select thecodec and then clickNow the key part in the Xvid Configuration window is thevalue:A value of 1 will give the highest quality and the largest file, with increasing numbers resulting in lower quality and smaller file. I'd recommend a value between 2 and 7 for YouTube purposes. If there are really fast scenes you'd want high quality (e.g. value of 2) to stop the movie becoming pixel soup. If you're doing a sniper camping scene without much visual activity, a lower quality value of 5 may be good enough and will result in a much smaller movie for quicker uploading. Here's an example of two quantiser values to illustrate the difference in quality:If you wish, you can also cut out some of the frames and shorten the movie via. If we wanted to cut out the first 5 seconds of a 15 second video, we'd set the starting position to 5000ms and the duration to 10000ms like so:One last thing is to make sure the audio settings are correct. Some tutorials suggest encoding the audio as an MP3 to shrink the video filesize but I find it significantly damages the quality of the audio after uploading to YouTube, not to mention being a bit of effort for little gain. We want to keep thing simple, so we'll just confirm the defaultis selected in themenu:Now to finish off the movie, we now encode it as an Xvid. Selectand type in a suitable name and hit. A progress window will show during the encoding process:That's it! You should now have a small Xvid AVI file, ranging from maybe 5-20MB for a 15 second clip depending on the encoding quality you selected. You should now be able to play it back in a regular media player and move onto the next section if you're happy with the results.Now that you have your final compressed video, uploading to video-sharing services like YouTube is now possible. There's usually not much to it. Click "Sign Up" at the top-right to create an account if you don't already have one. After you're signed in just clickYou'll be greeted with an Upload button that will allow you to select your Xvid encoded video:After you select it, the video will upload in the background while you're able to enter details about the video. Add a concise title and description as well as suitable tags that will help people find your video when using the Search feature.When you're finished entering the details, don't forget to hit Save! Depending on the speed of your connection and any concurrent activity, a 20MB file may take up to 20 minutes to upload. After the video is done, it will confirm the upload finished and your video will show up when you view your profile (under) after processing is done - which can take up to 15 mins to complete.Later on when viewing your video you can hitand change the preferences for the video. I generally enable the option to be able to screen viewers' comments before they are shown below the video. Why? Read this comic Here are a couple of videos I produced in TF2/L4D using the techniques discussed: To implement cyclic key bindings, we need to use aliases. Unfortunately aliases are not retained when you quit the game, so you'll need to place it in a script that gets automatically run when the game starts. So create a fresh file with one of the following names depending on the game (don't forget the base game path!):Just make sure that if you're creating it in notepad/wordpad that it uses the trueextension (if unsure, place double quotation " marks around the filename when saving). In this file we add aliases:Alternatively you can right-click and save this file I prepared earlier into the config path. Now fire up the game and bind your demo-recording key to one of the aliases from the Console - you only need to do this once:So what will happen? On the first use of forward-slash, the game will start recording a demo called, then on the next use of the key, thenthen it will go back and start overwriting the first demo. Scripting purists will tell you to never bind keys inside aliases as they complicate things and make it more tedious to change the keyboard key since it's now in multiple places. But this method allows the game to remember (via the key binding) which demo you last recorded to even if you quit the game, allowing the next demo name in the list to be used instead of starting atevery time you launch the game.