in Politics, Raleigh, X-Geek

Converting Raleigh’s streaming media into open formats

The City of Raleigh now makes the meetings of the city council and other boards available as streaming media hosted by the company called Granicus. These streams are helpful for getting citizens (particularly geek citizens locked in a cubicle) a look at government happenings but they are offered in a proprietary Windows Media 9 format and not an open format like Xvid, MPEG4 and the like. Linux media players like Totem and Mplayer can play the existing streams but the streams’ lack of an index makes it impossible to skip through the sessions.

I’ve puzzled out how to get to the raw WMV9 files so that Mplayer’s twin, Mencoder, can covert them into Xvid format. I do this not only because I want to watch them using Linux, but also so I can store them myself for later review and reference.

Here’s how it works. First, go to the City of Raleigh’s streaming media page and find the meeting you’re interested in converting. You need the clip id of the session you’re interested in watching. If there is an “agenda” link for your meeting, hovering your mouse over this link should show the clip id at the end of the url shown at the bottom of your browser. If there is no “agenda” link for your meeting, you may take a guess at the clip_id based on the order of the meetings or search the page’s HTML source code for the string “clip_id.” The latest meeting’s clip id is 376, for instance.

Next, take the clip id and input it into this script (i.e., “getsession.sh 376”):

#!/bin/bash
URL="http://raleigh.granicus.com/ASX.php?view_id=2&clip_id=$1"
NEWURL=`wget -q -O - $URL |grep mms|sed -e 's/.*mms/mms/' -e 's/?wmcache.*//'`

/usr/bin/mencoder $NEWURL -o rcc-$1.avi -oac copy -ovc xvid -xvidencopts pass=1

This simple script will create an Xvid-encoded file called rcc-.avi in the current directory, which you can then watch with “mplayer -idx rcc-376.avi” or store on your own server.

There are probably many ways to clean this script up and perhaps optimize mencoder’s work. Improvements from the peanut gallery are greatly appreciated.