I'll try do my best to share the steps I've taken to fix lag on video with my raspberry pi.
I'm building a robot that has a raspberry pi mounted on top of it, which talks to an app for android through uv4l. it needs to be able to get a reliable picture as the requirements for the robot need it to be responsive to changes while the video runs.
I'm running an ALFA NETWORK AIP-W525H v2 router
Raspberry Pi 3 Model B board.
Lenovo Tablet TB2-X30F
I'm trying to get 300ms between the pi and whatever device will be used to show the video. I have an android app that uses a webview of the stream provided by uv4l. http://ip-address-pi:8080/stream/video.mjpeg
I also have nginx loaded to provide a python program for saving pictures on the camera to the android phone.
Nginx has two configurations, one for providing media queries for the video based on device size, and the other running a python program with uwsgi.
I tried stopping nginx which reduces the lag slightly, but not enough to make it playable for the purpose of the robot.
I tried enable QOS on the router to give priority to the tablet, which managed to reduce the lag slightly.
It's to be expected, that if it is on the router that is provided for the robot, lag would be less. if i try it on the home network the lag is worse, sometimes being 4 seconds of lag, but that's to be expected because we have many devices using the network at any given time.
I tried using VLC to stream it to itself on another computer, but the lag was still there.
I tried seeing how much CPU and memory usage while streaming and uv4l is approximately using 20% of both while video is going.
Any help appreciated! I know someone here must have the answer to this!