TfL feeds

·

TfL have released several XML feeds of information, including tube station and traffic webcam locations.

As Ed Parsons says, there should be so much more, but it's a good start.

Here are the traffic webcams on a Google Map (click a pin for the image).

Update: video capture:

Here's some code for fetching webcam images (run it with cron then make a movie/analyse traffic density/mash up with traffic data?):

<?php
$dir = 'tfl-webcam-images';
if (!file_exists($dir))
  mkdir($dir, 0700, TRUE); // recursive
array_shift($argv);
if (!empty($argv)) // pass in a space-separated list of image URLs
  $urls = $argv;
else
  $urls = array( // or add them here
    'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/549702.jpg',
    'http://www.tfl.gov.uk/tfl/livetravelnews/trafficcams/cctv/541411.jpg',
    );
do {
  $now = time();
  foreach ($urls as $url){
    $out = sprintf('%s/%s-%d.jpg', $dir, md5($url), $now);
    system(sprintf('wget %s --output-document=%s', escapeshellarg($url), escapeshellarg($out)));
  }
  sleep(60); // every minute
} while (++$i < 1440); // 60 * 24 = 1 day

Making a movie with mencoder and x264 (and optionally ffmpeg2theora, for embedding):

  1. mencoder "mf://*.jpg" -mf fps=25 -ovc x264 -o out.mp4
  2. ffmpeg2theora out.mp4