question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce video stream lag

See original GitHub issue

Currently, the lag is between 0.8s and 1.20s using ustreamer.

I recommend swapping it out with mjpg-streamer. As the HDMI-to-USB dongle is providing video in mjpeg format, mjpg streamer can stream it with notably lower lag. From my tests, i would say it is bellow 0.2s. Can you please check?

Installation steps for standalone server:

sudo apt update
sudo apt upgrade

sudo apt-get install build-essential libjpeg8-dev imagemagick libv4l-dev cmake git

mkdir ~/mjpg-streamer
cd ~/mjpg-streamer
 
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
 
make
sudo make install

Start the video stream server by running: /usr/local/bin/mjpg_streamer -i "input_uvc.so -f 30 -r 1920x1080" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"

Yes, I was running it at 1080p at 30 fps. Didn’t see any lag between my local and browser stream.

The stream runs on http://raspberrypi:8080/?action=stream

I played around with it for a bit and it seems to perform MUCH faster then ustream with nginx proxy.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:26

github_iconTop GitHub Comments

1reaction
mtlynchcommented, Aug 11, 2020

Thanks for measuring! I removed those parameters in the latest ansible-role-tinypilot:

0reactions
somik123commented, Aug 11, 2020

@somik123 - which of those flag changes affects the latency? A lot of them are superficial like changing from the short flag name to the long flag name. -s :: just changes ustreamer to listen on all interfaces rather than on localhost (--host 127.0.0.1), which shouldn’t affect latency

From what i gathered, removing these two seemed to be the key in reducing latency.

  --workers 4 \
  --drop-same-frames 30 \

As you said, --format jpeg overrides --encoder hw and ignores -q 100 so keeping or removing them should not matter.

This is the current setting and even with nginx proxy, the latency is well bellow 200ms over 5Ghz WiFi compared to 1000ms from before.

/opt/ustreamer/ustreamer \
  -m jpeg -r 1920x1080 -q 100 -s :: -p 8001 -f 30 \
  --persistent 
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reduce lag while livestreaming video - Mashable
How to reduce lag while livestreaming video · Plug directly into your modem · Check your stream settings · Using the right software...
Read more >
Why is my Stream Lagging and How to Fix it? - Kiloview
Solution 1: Adjust your OBS Setting · Set the bitrate to 2500 Kbps. · Set the video encoder to x264 (default value). ·...
Read more >
Why is My Stream Lagging? How to Reduce a Lag
5 Tips to Reduce Lag Streaming · Close All Apps You aren't Using · Use the Appropriate Software · Adjust the Stream Settings...
Read more >
How to fix a laggy stream? - YouTube
Are you struggling with a laggy stream ? Have you noticed pixelation, stuttering, dropped frames, or connection issues when you go live ?...
Read more >
How to *FIX* a Laggy Stream | OBS Best Settings Tutorial
Even if you have a decent PC and internet, streaming may still be a struggle. I know it was for me as well....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found