Permalink
Browse files

Initial commit

  • Loading branch information...
wlach committed May 7, 2012
0 parents commit c595e8da7c4859b0a084bfbb9df981fa2dbe009e
Showing with 102 additions and 0 deletions.
  1. +12 −0 README.md
  2. +4 −0 bin/record-video.sh
  3. +37 −0 bin/retroscope
  4. +3 −0 bin/runretro.sh
  5. +4 −0 bootstrap.sh
  6. +42 −0 html/index.html
@@ -0,0 +1,12 @@
+This is just a cheesey one-night hack, so there's only minimal documentation.
+
+Requirements: ffmpeg (`sudo apt-get install -y ffmpeg virtualenv-python` on
+Ubuntu), a Linux laptop with a webcam accessible via '/dev/video'.
+
+Quick start:
+
+ ./bootstrap.sh
+ ./bin/runretro.sh
+
+Then connect a web browser to the ip:port that the aforementioned script
+spits out.
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm -f $1
+ffmpeg -s 320x240 -f video4linux2 -i /dev/video0 -isync -vcodec libvpx -vb 768000 -r 10 -vsync 1 -f alsa -ac 1 -f webm $1 -vframes 50
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import os
+import shutil
+import time
+import mozhttpd
+import tempfile
+import sys
+
+SERVER_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../html"))
+RECORD_VIDEO = os.path.join(os.path.dirname(__file__), "record-video.sh")
+
+def get_video_fname(num):
+ return os.path.join(SERVER_DIR, "video%s.webm" % num)
+
+# create the server
+host = mozhttpd.iface.get_lan_ip()
+server = mozhttpd.MozHttpd(host=host, port=8080, docroot=SERVER_DIR)
+
+server.start(block=False)
+
+print "Serving '%s' at %s:%s" % (server.docroot, server.host, server.port)
+
+while 1:
+ # Move any existing movies back
+ for i in reversed(range(1,4)):
+ try:
+ shutil.copyfile(get_video_fname(i-1), get_video_fname(i))
+ except IOError:
+ # ignore ioerrors, most likely it just means the file doesn't exist yet
+ pass
+
+ tmp = tempfile.NamedTemporaryFile()
+ os.system("%s %s > /dev/null 2>&1" % (RECORD_VIDEO, tmp.name))
+ shutil.copyfile(tmp.name, get_video_fname(0))
+ time.sleep(30)
+
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+./bin/python ./bin/retroscope
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+virtualenv .
+./bin/pip install mozhttpd
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="refresh" content="60">
+ <meta charset="utf-8">
+</head>
+<body>
+<center>
+<table style="width:100%;">
+ <tr>
+ <td id="video0">
+ <
+ </td>
+ <td id="video1">
+ </td>
+ </tr>
+ <tr>
+ <td id="video2">
+ </td>
+ <td id="video3">
+ </td>
+ </tr>
+</table>
+</center>
+ <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
+ <script>
+ $(document).ready(function () {
+ function updateDimensions() {
+ var tileHeight = Math.max(64, ($(window).height() / 2) - 16);
+ for (var i=0; i<4; i++) {
+ var rand = parseInt(1000*Math.random());
+ $("#video" + i).html("<video src='video" + i + ".webm?var=" + rand +"' style='width:100%; height: " + tileHeight + "px;' autoplay loop></video>");
+ }
+ }
+ updateDimensions();
+ $(window).resize(function() {
+ updateDimensions();
+ });
+ });
+ </script>
+</body>
+</html>

0 comments on commit c595e8d

Please sign in to comment.