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.

One thought on “Generate a movie from SUMO

  1. Pingback: MattF’s ramblings » Blog Archive » Generating HTML 5 videos for Chrome (with Virtualdub Mod)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>