Bethesda's epic sci-fi RPG is here, and it's a big one. From shipbuilding to exploring the surface of Mars, our thoughts so far.
Starfield Review... In Progress
The first trailer for Grand Theft Auto 6 is finally here.
Grand Theft Auto 6 Trailer
We take an in-depth look at Avatar: Frontiers of Pandora and tell you why it should be heavily on your radar!
Avatar: Frontiers of Pandora - a Deep-Dive into its Potential
Range-wise, the ROG Rapture GT6 is phenomenal, and it's ideal for all gaming and non-gaming-related tasks.
ASUS ROG Rapture GT6 WiFi 6 Mesh System Review
How to Make Team Fortress 2, Left 4 Dead and Counter-Strike Source Videos for YouTube
Post by parabol @ 01:04pm 15/12/08 | Comments
Regular contributor parabol takes us through the steps involved in creating videos from any Source engine game - including Team Fortress 2, Left 4 Dead and Counter-Strike: Source, to name but a few - and getting it online so you can pimp it to all your friends via YouTube.

:: Introduction ::

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 software
2. Record demos in TF2/L4D/CSS

3. Encode the demos as videos
4. Process and compress the videos
5. Upload to YouTube

All 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.

:: Game Path ::

One thing to note is the game path. If you have Steam installed under C:\Steam, you'll have to locate and remember one of the following paths depending on which game you are targetting:

C:\Steam\steamapps\-username-\team fortress 2
C:\Steam\steamapps\common\left 4 dead
C:\Steam\steamapps\-username-\counter-strike source

... where -username- is your Steam login name.

Note #0: All paths and files referred to in tutorial will be relative to this respective base path!

Note #1: 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!

:: Preparation ::

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.

:: Recording a Demo in-game ::

If you haven't already done so in the past, enable the Developer Console. For TF2/CSS, it's under Options->Keyboard->Advanced. For L4D, it's under Options->Keyboard/Mouse.




Now bring up the Console with the ~ (tilde) key. 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: bind / "stop; record mydemo"

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 mydemo. 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.

:: Encoding Demos ::

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 the stop command in the Console to make sure you're not recording.

Important: 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!

Update: 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 type demoui in the Console to bring up the demo playback interface. Hit the Load button 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 click Edit in DemoUI, then New and select Play Commands:



Now 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 TimeUseTick, the tick value to 5000, then add the two commands to be executed at that tick:

host_framerate 60; startmovie mymovie avi



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 between mymovie and avi, as avi is a parameter and not the file extension! Next hit OK to save the command, then create a new Play Commands entry, this time for ending the movie and stopping demo playback in one go. Enter a suitable name again, set TimeUseTick, tick value at 8000, and the following commands:

endmovie; stopdemo



Hit OK and you should see a summary of your entries:



Hit OK again to return to the demo playback window. Now hit Stop in 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:

demo_gototick 4000

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 select Full Frames (Uncompressed):



This 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.


:: Processing the video ::

We now have a massive uncompressed video located in the base TF2/L4D/CSS path. It should be called mymovie.avi. Start VirtualDub and either drag the AVI file onto the program window, or select File->Open Video File and select the video. It should open up showing the first frame:



We then configure the compression via Video->Compression. Select the Xvid codec and then click Configure:




Now the key part in the Xvid Configuration window is the Target quantizer value:



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 Video->Select Range. 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 default Direct Stream Audio is selected in the Audio menu:



Now to finish off the movie, we now encode it as an Xvid. Select File->Save as AVI and type in a suitable name and hit Save. 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.

:: Uploading the video ::

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 click Upload:



You'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 My Videos) after processing is done - which can take up to 15 mins to complete.



Later on when viewing your video you can hit Edit and 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.


That's it, hope you enjoyed the tutorial!

Here are a couple of videos I produced in TF2/L4D using the techniques discussed:





:: Advanced - Cyclic Demos ::

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!):

tf\cfg\autoexec.cfg
left 4 dead\cfg\autoexec.cfg
cstrike\cfg\autoexec.cfg

Just make sure that if you're creating it in notepad/wordpad that it uses the true .cfg extension (if unsure, place double quotation " marks around the filename when saving). In this file we add aliases:

alias "record_0" "stop; record mydemo_0; bind / record_1"
alias "record_1" "stop; record mydemo_1; bind / record_2"
alias "record_2" "stop; record mydemo_2; bind / record_0"


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:

bind / "record_0"

So what will happen? On the first use of forward-slash, the game will start recording a demo called mydemo_0, then on the next use of the key mydemo_1, then mydemo_2 then 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 at mydemo_0 every time you launch the game.



Latest Comments
Thundercracker
Posted 01:46pm 15/12/08
Nice work parabol.
eu4ia
Posted 01:53pm 15/12/08
Nice work parabol.
+1
Davetron
Posted 02:32pm 15/12/08
Nice tutorial! Can I ask why you leave out the audio compression though?

Using this tutorial, you actually end up with quite a large audio stream (even bigger than the video stream) It might not be a huge problem for short videos but if you really want to make your files smaller and quicker to upload then encoding to mp3 audio is a must.


By default VirtualDub doesn't provide good quality mp3 encoding settings, that's probably why you found the quality to be bad when you tried encoding to mp3. You need to add a proper codec.

I suggest installing LAME ACM MP3 Codec http://www.free-codecs.com/download/LAME_ACM_Codec.htm (also free)
Then you will have decent quality compression options to encode your audio with.



last edited by Davetron at 14:31:03 15/Dec/08

last edited by Davetron at 14:32:16 15/Dec/08
trog
Posted 02:34pm 15/12/08
davetron, good point dude - though Id recommend using the LAME ACM codec from rarewares (not for any reason, I just prefer it over free-codecs.com - http://www.rarewares.org/mp3-lame-dshow-acm.php)
ctd
Posted 02:41pm 15/12/08
You can also bring up the demoui by pressing shift+f4 or something similar. Fairly sure it is f4.
Midda
Posted 02:53pm 15/12/08
It's Shift+F2
StreX
Posted 02:53pm 15/12/08
wish i bothered to figure out this s*** ages ago.

i could have been sitting here basking in the glow of all the positive youtube comments i would have no doubt been receiving for my epic spy vids.
Pinky
Posted 02:56pm 15/12/08
I'm a Digg h8r but I want to do my bit to make this front page. +1 from me.
ctd
Posted 02:58pm 15/12/08
I got videos on youtubes of our epic first night of l4d no mercy expert finale. Only did it the quick way with fraps so its fairly terrible quality though.
StreX
Posted 03:20pm 15/12/08
hah sweet.

all those noobs in the comments saying that it must be on easy mode. we just make it look easy (after the first 5 failed attempts lawl) :P
stinky
Posted 04:01pm 15/12/08
you guys must have been on easy mode!
parabol
Posted 11:31pm 15/12/08
Nice tutorial! Can I ask why you leave out the audio compression though?

I figured it was a YouTube problem, as I mentioned in the tutorial.

I experimented with a range of MP3 bit and sampling rates, which sounded perfectly fine and high quality when listening-to/watching the output encoded movie. After uploading the exact same AVI to YouTube and playing it back though, the audio was just terrible. Never figured out why so I just stuck to keeping the original stream untouched.
Commenting has been locked for this item.
12 Comments
Show