Parsing Data from Parlvu

From VisibleGovernment

Jump to: navigation, search

Parsing Video Data from ParlVU

Step 1.

Visit ParlVU and find the link to the video stream you want to record. The link will appear like http://parlvu.parl.gc.ca/parlvu/asx/A001-V-EN-VH.asx

Step 2 (optional). (Manual Recording)

Plug this url into a Video application like VLC.

Step 3. (Automatic recording)

You will need to parse the ASX to get the actual location of the stream. The following PHP snippet follows two levels deep into the ASX which works with ParlVU but may not continue to work perpetually. The result will be a mms stream url.

asxparse.php

<?php
$file = file_get_contents("http://parlvu.parl.gc.ca/parlvu/asx/A001-V-EN-VH.asx");
preg_match('/"(http:\/\/[^"]+)"/',$file,$matches);
$file2 = file_get_contents($matches[1]);
preg_match('/"(mms:\/\/[^"]+)"/',$file2,$matches2);
echo $matches2[1];

Step 4.

Record the MMS stream using mEncoder. (Records to mpg format). Endpos defines how long to record for in seconds [but cannot be less than 30 seconds or so, or it will break]

mencoder mms://wms.example.org/200550/HOCA001VENVH?EVID=95&Rate=500V&Format=Win&SegNum=2&RegID=0 -ovc lavc -oac mp3lame -vf harddup -fps 30 -lavcopts vbitrate=500:vcodec=mpeg2video:keyint=500 -o savefile.mpg -of mpeg -endpos 90

Personal tools