Previously I wrote about the remote control parts of the Telepresence Dalek, but that’s only half the problem. The other half is video, both to provide a view of the Dalek’s PoV for the operator and to display the operator’s face on the Dalek. I’d been thinking about this problem for several months before actually getting around to doing anything for it, so I’d already come up with a plan of attack based off re-using various things I already owned, and I had a variety of people’s posts advising how to do this, so it should be nice and easy right? Little did I know…
So, option number one: use this guide to doing Raspberry Pi-based streaming, plus a little LCD screen on the front of one to display the operator’s face. I’d already ended up buying a Pi 2, because my original Pi had decided to stop working properly in the couple of years since the last time I did anything with it (and new project means excuse for new toys). This would use the Janus WebRTC gateway, plus either VLC or a browser to display the video on the Pi. Some parts of this were in fact nice and easy: the screen just worked, and I had X happily running on it with very little effort. However, unlike the guide I wasn’t using the official Raspberry Pi camera, but a random (somewhat old) webcam, which means that nice GStreamer pipeline part way down the page just doesn’t work because my camera didn’t have onboard h264. Cue several hours of frustration, trying to figure out why various alternate pipeline ideas won’t work, but unfortunately GStreamer is a horrible, horrible thing to debug. Basically, unless you’re either using Playbin, it’s very hard. On the plus side, it’ll let you plug just about anything audio/video together, but on the downside it’ll just plug things together with very little checking and figuring out where you broke things is frustrating as all heck.
Admittedly, even if I’d gotten this working, it turns out that customising Janus would have been a lot of pain, so maybe that wasn’t the best of options. Janus had the nice feature of being able to use a local video feed as input, but it wasn’t worth the pain. Along the way I also tried out various things with ffserver and uv4l, which had some success, but weren’t really intended for web-browser streaming, which is what I wanted, as that would be the best way to let the most people use the Dalek.
Right, so option number two: grab my previous phone, which turns out to do WebRTC nicely (both as display and webcam), stick it to the front of the Dalek and then run EasyRTC on the Pi. EasyRTC, as the name (correctly for once) suggests, both has nice out-of-the-box WebRTC demos and is much, much easier to customise. You’ll need the custom Node.js setup for your Pi, but that’s all pretty simple. I’d advise making some self-signed certs, because that way you don’t have to repeatedly tell your browser that you want it to let your site grab your video, but other than that there’s some minimal Node.js code to make the EasyRTC server run, and other more advanced versions of stuff I did last time, which mostly kinda works, as WebRTC is still painful on a short time budget. In the end I actually ended up running the server on my home server, as that made it easier to give a URL to the outside world than running it on a Raspberry Pi inside a hotel’s wi-fi.
Of course, if you’ve got this far, you’d probably like to know how well it actually did in the Dalekdrome. Short answer: not very well. Hotel wi-fi is basically evil, and the WebRTC bits that worked fine outside just didn’t work inside the hotel, and the Spark couldn’t authenticate because it hasn’t got a web browser (but that’s a topic for another post). With a handful of hours to go I used my phone as a hotspot for the Spark, created a Skype account for the other phone stuck to the front of the Dalek, and valiantly entered the competition. Sadly, the controls weren’t playing ball and I only got about half a metre into the obstacle course before having to abandon it 🙁 I did however amuse at least one small child, and I liked how my Dalek looked in the middle of all the others, which is always a plus.
Things learned for next time: If you’ve got 6 months for a project, don’t procrastinate until about 3 weeks to go, and assume that video, even in these modern times is non-trivial. It’s a lot easier to do in-browser video these days (i.e possible rather than nigh-impossible), but it’s still not easy, especially with phones.