Fast and simple way to encode replays

Posted June 23rd, 2010 by CyberShadow in Uncategorized

If you’ve ever created a Worms movie, you probably had to import the exported PNG frames into VirtualDub and use it to create an AVI file (as described here), which you later imported into your video editing application and encoded to something you can put online. (Or you could have taken the lazy path and used a screen capturing application, which is simpler and has sound at the expense of visual quality.) Anyway, both of these methods involve a lot of work if you just want to convert a replay (or a part of it) and put it online.

Here’s a simple method to get a file streamable by Flash Player in three steps, using AviSynth and x264:

  1. Export the replay to PNG frames as usual;
  2. Create a video.avs file in the directory with the exported frames, with the following line:
    ImageSource("video_%06d.png", start=0, end=1000, fps=50, pixel_type = "rgb32")
    Set the end parameter with the number of the last frame. Similarly, set the fps parameter correspondingly to the Frame skip option you specified in step 1 (50 FPS for frame skip=1, 25 FPS for frame skip=2, etc.).
  3. From the command-line, run:
    x264 video.avs -o video.mp4
    Add x264 options by preference. For example, use --crf to control quality (lower is better) and --preset veryslow to improve compression.

That’s it – the resulting video.mp4 file will contain the encoded video, ready to stream!

As an additional bonus, if your video editing software supports H.264 and any of the output container formats supported by x264, you can use this together with --crf 0 for lossless H.264 compression. Keep in mind that x264 doesn’t support the RGB colorspace though, and will convert the video to YUV 4:2:0.

P.S. We plan to add the possibility to directly extract video from replays (using DirectShow) to W:A, together with sound. The biggest obstacle is that it looks like we need to write our own software mixer to mix W:A’s sound samples to the output.

Leave a Reply