Extremely low latency IP video for a weird use case [Wendell]

Before you read any of this let me preface this with "Don't judge me!"

Okay, so in addition to PC stuff, in my spare time I do model trains. I've got a PC connected to my layout using JMRI (java model RR interface) and a Digitrax DCC system, which uses pulses to allow control of multiple independent locomotives across a single circuit.

The reason I need to do video is because I have a friend who also likes to use the layout, but he's on the other side of town. He has VPN access to my network (I've got pfSense, a Unifi AP, Proxmox, and a few older Linux machines) so he can access the JMRI web throttle page just fine, allowing him to control aspects of the layout from anywhere, with less than half a second of latency. The trick is that for that to be useful, he has to be able to see what he's doing...

Up until now we've been propping up my Nexus tablet and using Skype or Google Hangouts, but we need a better option. Because the locomotives all make noise, its hard to hear him from the crappy little Nexus speaker. I have an idea though:

Since I use my phone as a wireless throttle (via functionality in JMRI) I always have it with me when using the trains. My idea was to use the phone with Skype and earphones for voice, so that I can hear him and he can hear me regardless of how loud the trains are, or how far away from the camera mic I am.

The thing I need help with is video.

TLDR-I need a way to use a webcam connected to a Debian Linux machine to stream reasonably good video (360p 25fps would be fine) to him, with less than a second of latency. We basically need a one-way Skype. I was going to just use Skype, but the laptop I'm using is a 1.3GHz Celeron so Skype is murderous on that CPU. Is there a program to do what I need? It really doesn't matter how he connects, he can use VLC or something if that'll be better.

To clarify, yes, we want to be able to drive toy trains over a VPN using Skype or similar.

Now that everyone has sufficiently judged me, does anyone have any ideas?

You could use open broadcaster streams and have him connect to it via VLC.

Webcam wise, I am not the one answer that.

OBS was my original idea, but idk if it works under Linux...I don't think it does but I could be wrong...or maybe there's an alternative?

dude, no one is going to judge you :D

We are all adults who like to play with toys every now and again.. and train sets are pretty cool

Waiting to see wendell answer on this

Webcam video is already overkill imo. Proprietary digital video formats are not always very efficient for this type of applications. I would use simple super cheap analogue composite cctv cams (easy to send over analogue wireless with minimal energy, digital transmission is waaaaaay more expensive), capture them and real-time transcode in very low native quality (120-160-240p something like that) using a standard open source streamer (any, you don't need OBS to stream, any open source media streaming application has this functionality on board by default, the only benefit of OBS coming to linux is the ability to use a GUI to handle overlays, green screens, etc..., but for streaming as such, OBS will never be the best solution, because it's way too bloated in typical Windows tradition for use as just a streaming server).

Another option is to use any ready-made IP cam (those things are dirt cheap), and in linux you can do with that stream whatever you want, or you can tap into the IP cam directly (because they use a standard linux media stream server of their own on a tiny little SoC, so if those things can do video streaming server, lolz, a Celeron with more than half a billion transistors can most certainly do it).

They have OBS up on github. You may want to go with what Zoltan said to reduce bandwidth 

Yeah I had looked at several of the little "magic ready to go super easy" IP cams, but I was trying to avoid spending any extra money :P I looked at using FluMotion, but it seems awfully CPU-intensive, and I imagine the latency would be pretty bad. Ultimately what would be ideal is to have multiple cams he can see at once (for the various parts of the layout, its a 5x9 table so you really can just BARELY see everything you need to from a fixed birds eye view) so that's why I wanted to use webcams.

Would something like ZoneMinder work? (Assuming there were drivers for my camera) that would be great since he would be able to see multiple cams at once, and again sound doesn't matter because we use Skype and my headphones/android phone for that.

Oh by the way, if it matters, the Linux box in question already has Lighttpd on it for a little landing page for guests (you scan a QR code on the front of the table to get there and it guides you through getting the throttle on your device) so if I need to run a web app it should work as long as it doesn't require Apache-specific functionality.

Also what do you mean by "analog video" transmission? I can't just run a composite cable to his house lol he's 40 mins down the road from me, thus the use of OpenVPN

I mean that you can put a cctv module onto a train and wirelessly (analogue) bring it to the PC,where it's captured and codec-ed into a digital low bitrate stream.

There are several options. Not with Debian stable, but with a recent kernel (3.18 and up, so you'll have to use Debian Sid if you want to stick to Debian), you can actually share a USB socket (like a webcam) over TCP/IP directly. That's a possibility that's probably the most efficient, and the bandwidth will not be a lot higher than using a compressed video format if you're going with a really low res. Another possibility is to use capture and codec it and stream it, and there the choice is enormous, but I would suggest using a recent kernel yet again, and taking advantage of h.264 encoding. You can let multiple streams be served (even a celeron can do that no problem) and then tap into the URL of the stream you want.

Oh I see. What is it that Wendell uses for streaming during The Tek? Isn't it just in a browser or a VLC RTSP window or something? It would have to be low latency since they record it in real time, so if I could work something out similar to that just lower resolution and framerate then that would be amazing

If need be, I can bring in a 1.9GHz AMD Sempron laptop with 512mb of RAM and 128mb of GPU RAM, but the Celeron one has 2GB of RAM so I was using that one instead since it can likely multitask better.

Hey guys! I've been fiddling with this thing for a couple days now and it SEEMS like the best option would be to use avconv and stream over either RTP or UDP without doing any transcoding (and thus using almost no CPU on the host machine) but I can't figure out what's going wrong. When I set up the stream on the machine connected to the cam, I try RTP streaming (with the codec set to copy or mpegts it does the same thing) and set the destination IP and port to rtp://remotemachineIP:1234 and then when I go to open the stream in VLC on said machine I choose open network stream and put in rtp://@:1234 and it just sits there. No errors, just sits there like its buffering, only itll sit there for 2 mins or more.


Well I tried FluMotion and its slug slow, plus I don't think its really built to be fast and small. I don't need scalability, I need low latency. Does anyone know how Logan and Wendell have the Tek set up to record? I know one of them streams to the other one but I don't know who does which and if there's some piece of software they use that I could use with this

If anybody knows anything about avconv/ffmpeg then HELP ME PLEASE

USB webcams are slow. I use obs and aver live gamer capture 3 because I got it for $20 . USB video converters are slow also.

Hikvision is the only brand of IP camera. About $100 at the low end and built in Linux rtmp and nginx . also you can maybe find axis brand 4 port BNC to IP adapters for 50 bux. You can hook up 4 analog cams and get rtmp out the other side. That works well too. 

The stream setup I use has about 300 ms of latency give or take. Which is not terrible but I'm always tinkering with it to improve it . 

 The raspberry pi camera plus nginx is disturbingly low latency also. 


Okay thank you

I know I SHOULD do this the "right" way and I probably will here shortly, but I got to fiddling again today and I was wondering how the USB webcam is so slow (about 2 seconds of latency) when I play it through avplay, but then when I open it in guvcview its so low latency I can't even count a second. I'm running this on Debian 7 under LXDE, and the command I was using is "avplay -f video4linux2 -i /dev/video0" which pulls up a little GUI window of the webcam feed. It's good quality but about 2 seconds of latency. Running the command "guvcview" pulls up a window with the same resolution, but low enough latency I can't even tell.

I finally ended up getting the streaming working from avconv to VLC, I had a firewall rule jacked up (yes I know I'm a dummy :P) and if I stream with UDP at 640x480 using mpeg2video, I still get 2 seconds of latency. I thought it was the network but I'm thinking its avconv now that I found out avplay does it too...

Is there a way that I could use either gStreamer (I tried but I could not for the life of me figure out how it works, but it looks powerful) or use guvcview and avconv to stream at a latency of a second or less?

Sorry for the dumb questions, I know I should just buy a "real" IP camera or a nice capture card, but I can't right now so I'm trying to figure some stuff out.