Any tips on reducing lag when viewing remotely?

wrybread

Pulling my weight
Sep 12, 2018
256
119
San Francisco
I'm working on an interface to view my camera through a semi-public web interface with pan, zoom and preset controls, and I've gotten it down to about a 3 or 4 second delay, but I'm curious if anyone has figured out a way to get less than that?

I'm streaming through YouTube Live using their "ultra low latency" setting, and have my camera resolution (sub stream 2) lowered to 720p.

The 3 or 4 second delay makes panning and zooming pretty awkward, though the presets work well and the PZ can then fine tune.

I have a feeling it's not possible to get less than this but thought I'd see if anyone has any interesting tricks.

Incidentally here's the ffmpeg command I'm using to send my stream to YouTube Live:

Code:
ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i "rtsp://admin:password@192.168.5.220:554/cam/realmonitor?channel=1&subtype=2" -tune zerolatency -vcodec libx264 -t 12:00:00 -pix_fmt + -c:v copy -c:a aac -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/je86-3cmm-sk1u-6ubs

The last part of that RTMP url (je86-3cmm-sk1u-6ubs) comes from your YouTube live dashboard (link).

And note that I'm broadcasting substream 2, which is the "subtype=2" in that URL. Change to 0 if broadcasting your main stream.

One thing I'm wondering about is that "-f flv" part of the commandline, which is re-encoding to FLV format of all things. If I set that to -f h264 it doesn't seem to work. Maybe that's slowing things down, and responsible for the significant loss in quality?

Anyway a bit more info here.
 
Last edited:
I think your latency is simply network delay. Camera to YT servers, request to YT servers, YT servers finding the feed, YT streaming it back out to you. Throw in the normal network delays and viola, latency. I see a second or two of latency using BI, UI3 and a VPN and that is a much more "direct" route.
 
I have found that if I use a VPN and Remote Desktop into the Windows 10 computer running BI, that the connection is pretty good with little lag. The method I am using is more steps than what you are trying to achieve with a web browser however.
 
I think your latency is simply network delay. Camera to YT servers, request to YT servers, YT servers finding the feed, YT streaming it back out to you. Throw in the normal network delays and viola, latency. I see a second or two of latency using BI, UI3 and a VPN and that is a much more "direct" route.

Agreed, but I'd love to shave another second off that latency. So far I've shaved about 15 seconds off the normal web interfaces like angelcam and ipcamlive and it's starting to be usable with PTZ, but is still a little hard to use.

My ffmpeg command for example is transcoding to FLV for reasons I can't figure out for example, maybe there's a more efficient solution there.