Jump to content
Sign in to follow this  

How to render a video from a gameplay demo, redux

Recommended Posts

Since ratty posted his how-to years ago, there's been a number of new tools that make it a bit less of a pain to get things rendered and rendered nicely, so I figured it's worth a new guide.  Still, if you want to keep it simple, ratty's way is still as effective after five years.


Note:  This tutorial assumes you are using a Windows system with specific tools on hand.  Ratty's how-to may work for the you lot using Mac or Linux, but I can't test those myself.


If you haven't looked at his how-to, I'm going to copy some stuff you may want to read over.

Feel free to start reading past the break.

  • Demo Recording Tools.  Valve Wiki on demos.  The important thing for this tutorial is the "Demo Player".  The other stuff isn't a bad read either, though.
  • Demo Video Creation.  Valve Wiki on the subject.  This how-to will also have instructions on how to do this with a specific application, so if you want to use something else, go for it.
  • Source Multiplayer Networking.  Again, from the Valve Wiki.  Along with times displayed in HH:MM:SS format, the Source Engine has a unit of time known as a "tick", the smallest unit that the engine processes.



Remember, this tutorial is developed with Windows in mind, and with my preferred method of recording.

YMMV and all.


What you'll need to start with:

  • A demo file.  Grab one off of the download page and use your favorite decent unarchiving tool to extract it to your TF2 directory or anywhere else.  You can also record first-person, client-side demos.
  • Lawena Recording Tool.  Also referred to as LWRT, this tool simplifies starting TF2 with specific settings, recording at a specific framerate and such.  I'm biased towards this tool, but there's also Almie's Recording Tool and probably a number more that I don't know exist.
    • If you're using LWRT, you will also need Java 7 if you don't have it.  Remember to prevent the installer from installing other crap, and disable the browser plugin if it starts up.
    • Installation method:  Extract the download into a directory of your choice and run lawena.exe.  An updated copy of the program will be downloaded to the directory.  Close the application.
    • Has Mac / Linux support too?, if you want to work with demos using this.
  • SrcDemo2.  This utility creates a userspace filesystem that catches uncompressed game frames and audio before it is written to the disk, processing it.  What does that mean for you?  Faster recording because you aren't bottlenecked by your drive's write speed.  Compressed image frames.  Compressed audio.  Frame blending to provide motion blur.  Shutter angle simulation, not that I have a clue what that one is.
    • If you're using SrcDemo2 along with LWRT, you will need Java 7 anyways.  You will need the x86 version, as...
    • To create that magical filesystem that does all that neat stuff, you will also need the Dokan library.
  • AviSynth (x86).  I like AviISynth as a free tool to create videos.
    • That said, I'm biased towards it because of its scriptability.
    • Read:  This is a tool that requires some knowledge of scripting in the process of creating videos.  There's tutorials here and there if you like the idea of a program that uses scripts to generate videos, but if you don't, the "Demo Video Creation" article has instructions to import frames into various other video editors.  I don't blame you.
    • If you're still interested, AvsPmod is a program that assists with working in AviSynth.
  • iPodME is a simple tool that can take AviSynth scripts and other video sources and spit out a compressed MP4 file with ease.
    • Note:  iPodME creates videos with a max resolution of 1280x720 and with a relatively low bitrate.  A possible alternative would be XMedia Recode, but that is crashing on me, so the search continues.
  • Combined Community Codec Pack.  If you can't play audio in the Vorbis format with your choice of media player, you'll want this if you decide to use audio in that format, as SrcDemo supports.

Once you have all of that, you can get started.


Part 1:  Rendering (with LWRT and SrcDemo)

  1. Start up Lawena Recording Tool through lawena.exe.  You should get a UAC prompt -- it needs access to the Windows Registry to read / write certain settings that TF2 uses, among other tasks the utility performs to cleanly switch to the recording setup and back to your default settings.  Accept said prompt, and proceed to configure the location to save raw frames to.
  2. Start up SrcDemo as an administrator.  Pick that previosly mentioned location as the folder that the game will save frames to, and pick a different location to save the final frames.  Look over the available parameters and set it up as you like.  Note the "Effective recording FPS" in that window.  Do not activate it yet.  If you do, LWRT will fail to launch TF2.  I've filed an issue on the LWRT code repository about it conflicting with SrcDemo2, but for now you should watch out for this.  A patch has been released that fixes this.  Go to Help About Updater Channel, pick the Development Channel, and restart.  Once you are at a version 4.1.2-9 or higher, you're set and can activate SrcDemo2 whenever you please.
  3. Head back to LWRT and change the FPS to match what it says in SrcDemo.
  4. Start Team Fortress 2 with the button at the bottom right of LWRT.
  5. Activate SrcDemo2.
  6. Take a read over the controls in the console window that pops up, as that's how you can work with LWRT.
  7. Load the demo by pressing SHIFT + F2, clicking on the "Load" button, and selecting your file through TF2's file browser.
  8. Skip through the demo to find the thing you want to record.  If you have any clue where in the demo it is, you can skip to near the specific tick.
  9. Tap SHIFT + F2 to close the demo player and press P to start recording.  Keep in mind that It'll be a tad bit slow when rendering, among other things.  Ratty's how-to starting at "Some glitches to be aware of:" gives some pointers on recording the action.
  10. Press P to stop recording.  Lawena supports taking multiple recordings with the same key, so just press P again to start recording.  You can record sixteen different sequences in one session before things begin to get overwritten.
  11. Once you're done with all that, press ESC to open up the menu and exit TF2.  LWRT will return your settings back to what they were, so you can start up TF2 again and play more games and make more scenes worth rendering.
  12. Deactivate SrcDemo.

Part 2:  Putting it together (via AviSynth and iPodME)

  1. As I said, I like AviSynth, so the instructions will use that.  If you favor something else, go for it!  (No, Windows Movie Maker won't work.  I don't know if VirtualDub supports PNG files, but it's worth a shot.)
  2. Open up your plain text editor of choice and put in the following, replacing things as needed:
    # This snippet assumes you have and are using, in the final frames directory:
    # The first recording "a1" in PNG format, with file names from a1_000001 to a1_000673.
    # Ogg Vorbis audio.
    # The FPS is the "final video FPS" as specified in SrcDemo^2, which I had set to 30.
    # Read the sequence of image files into "vid".
    # The "%06d" in the filename argument means "an six-digit integer value padded with zeroes", which is what we have.
    vid = ImageReader("a1_%06d.png", 1, 673, fps = 30)
    # Grab the audio.  
    aud = DirectShowSource("a1_.ogg")
    # Merge the video and audio together and spit them out to the media player.
    return AudioDub(vid, aud)
  3. Save it as "your-video-title-here.avs" in the same directory as the massive amount of PNG files.  Make sure that it is saved as an AVS file and not a text document.  Make sure the video works by opening "your-video-title-here.avs" in a 32-bit media player of choice.  May be a little slow loading there since you're loading a number of stills; you're mostly just testing to see that everything's as it should be.
  4. Open iPodME, drag and drop "your-video-title-here.avs" into the window, set the settings to Slow, Quality or whatever you'd like to set them as, and encode.
  5. Once you're done, you should have a newly created MP4 file with the filename "your-video-title-here.mp4".  You can upload that to YouTube, play it to make sure it definitely looks fine, or do whatever else you want with it.
  6. And that's about it!  If you don't plan on saving the original video frames, you can delete them.


The old discussion thread is here.

Edited by nosoop

Share this post

Link to post

Nvidia Shadowplay is a great alternative for anyone for has a video card that can support it (GTX650 series or greater). It can record video at 1080 at up to 60FPS without a hitch.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...