Category Archives: Video Processing

Generate a movie from SUMO

SUMO, the open-source traffic simulation tool, does not have a simple option to output a movie. Using TraCI, the UDP-based control interface for SUMO, you can quickly generate a set of images from your simulation:

import traci
import sys
import subprocess

#change if necessary
PORT = 8816

sumoProcess = subprocess.Popen("C:\\path\\to\\sumo-gui \"C:\\path\\to\\simfile.sumocfg\"", shell=True, stdout=sys.stdout)

print "SUMO Started"

step = 0
#Please note these numbers are x100 milliseconds only because the SUMO simulation is set to have timesteps of 0.1s - i.e. the numbers are not in time but in timesteps
#Set movie generation end
while step 25000): traci.gui.screenshot("View #0", "..\\figures\\figurepath\\sumovideo\\sumo2Dvideo"+str(step)+".png")
step += 1


Once this is done, you’ll have a set of images. Just open the first one in Virtualdub Mod, and it will show you all of them as a movie which you can output to the format of your choice – for example .webm.

Generating HTML 5 videos for Chrome (with Virtualdub Mod)

I finally took the time to educate myself on the virtues of HTML 5 video. I’ve been doing presentations in HTML for a while now, but had been using browser plugins, which were awkward. Chrome’s preferred format is “VP8″ inside a container called “webm”. I often am preparing videos for presentations with Virtualdub Mod, as its an extremely fast and simple (and free) way to quickly edit AVI video file(s) or image sequences into a compressed movie. And you can even generate modern .webm videos with it; here’s how:

  1. Download and install the Video for Windows VP8 codec. You can ignore the warning about 64bit systems, although its probably true that media player, powerpoint 64bit etc. won’t cope, VirtualDub is 32 bit and can use the codec. There is a VP8 DirectShow Filter available for playback on more modern video software (Video for Windows is, err, old).
  2. Edit video as normal. Go to File… Save As, as normal. Select the Matroska (.mkv) container, Full Processing mode and under Configure, select the Google VP8 codec. You can change the target bit rate if desired, but the default was fine for me.
  3. Save! Be sure to (re)name the file with a .webm extension – .webm is an extension of the Matroska format

Another way to prepare .webm files if you are just doing a conversion is to use VLC‘s Convert/Save function.