HackspaceHat part 2: Streaming to a remote sever

We’ve made more progress on the HackspaceHat (HackspaceHat is a telepresence hat for exploring Hackspaces). Part 1 has a bit more background.


  • We have a hat! At Barney’s suggestion it’s an Isambard Kingdom Brunel-style stovepipe hat (£6!), giving it a Bristol theme but also plenty of room for electronics / batteries etc. Other hackspaces would need to choose a hat appropriate to their locale.
  • We’ve decided on a means to ensure that people are aware that the camera and audio are being used. Our initial thought was an emergency services style flashing blue light, but Alaric had a better idea: an “On The Air” sign with a light built into the hat.
  • We did a local test of the components draped over the hat to work out the position of the camera.
  • We realised we should use it for reporting live from Bristol Mini Maker Faire!
  • We’ve managed to get it working on a remote server, after some bother with ec2.

Here’s some information about the remote part. It still doesn’t work on an ec2 instance and I’m quite baffled as to why not – any ideas appreciated. It’s very strange because it does work from within my house when run on an ec2. But not when accessed from anywhere else.

Here’s what I did:

  • Ran up a new instance of Ubuntu LTS 15.04 on ec2 under a VPC
  • Installed janus-gateway and gstreamer

I opened up all the ports required for Janus-gateway with my video stream (inbound ports):

Custom UDP Rule UDP 8004
Custom TCP Rule TCP 8088

I ran this test gstreamer pipeline, which just creates a testcard and streams it to port 8004 on localhost:

gst-launch-0.10 videotestsrc ! video/x-raw-rgb,width=640,height=480,framerate=30/1 ! videoscale ! videorate ! ffmpegcolorspace ! timeoverlay ! x264enc bitrate=256000 profile=1 tune=zerolatency ! rtph264pay ! udpsink host= port=8004

Downloaded my testpage into /usr/share/nginx/www/

cd /var/www/html
sudo curl -O https://gist.githubusercontent.com/libbymiller/70ad942d070853167659/raw/acc38f4ccefb2c333a4cca460ec52a3151cbeebd/janus-gateway-streamtest.html

Started Janus gateway with this config at /opt/janus/etc/janus/janus.plugin.streaming.cfg:

type = rtp
id = 1234
description = H.264 live stream coming from gstreamer
audio = no
video = yes
videoport = 8004
videopt = 126
videortpmap = H264/90000
videofmtp = profile-level-id=42e01f\;packetization-mode=1

/opt/janus/bin/janus -F /opt/janus/etc/janus

Went to http://<ec2_public_ip>/janus-gateway-streamtest.html on Firefox 39.

Expected behaviour: see a testcard, like this:


…and inside my home network I do, but on any other network, I don’t see anything, and sometimes get an ICE error in the console:

Object { janus: "hangup", session_id: 10826300, sender: 1905332350, reason: "ICE failed" } janus.js:196:3


Exactly the same set up on an identical Linode instance works perfectly, from everywhere.

The difference might be that ec2 instances have all incoming ports firewalled by default, but it’s very strange even so. Why would it only work in my house?

Anyway, it works! sort of! I set up a gstreamer pipeline on a pi 2 sending its streams to the linode instance and that was fine, though not very peer-to-peer (kudos to AndrewN for arguing that that was actually more efficient if there are multiple clients accessing it).

danbri and I tested it Bristol->Sarajevo with an irc command channel (“turn right!”).

It kind of works over 3G too, which raises interesting possibilities.

Next jobs:

  • Try and make it more p2p
  • Run up a stun / turn server instead of using the Janus defaults
  • Add in an audio command channel
  • Continue investigating the ec2 problems