Raspberry Pi no delay (<10ms) video stream
Asked Answered
W

3

14

I'm building quadcopter based on Raspberry Pi. I want to stream video from webcam via cellular conection to my computer. I tryed ffmpeg and mjpg but it has to big delay to make it possible to control Quad only with watching video.

My question is if it's possible to stream video with realy small delay (so small that I will be able to drive quad without problems)?

If Raspberry's hardware isn't good enough, BeagleBord may do it? Also, mounting smartphone to quad will be last possible solution but I prefer soulution with Pi.

UPDATE: I have used gstreamer for the streaming and Raspberry Pi camera. It turns out to have really small amount of delay. 10ms is somewhat impossible but I managed to cut delay down to 20ms.

Wotton answered 25/5, 2013 at 14:13 Comment(3)
I would check to see if you can do it from a phone via cell network to your desktop without worrying about the raspi. You may find the latency of the cell network is just not food enough for what you want. The AR-Drone is going over WiFI. A cell connection can't be quicker, but will definately be slower - possibly with more latency than you want.Weeden
I did it and stream was realy slow. I will use ordinary FPV and make OSC (on screen display) by myself using PiWotton
I really doubt that even 20ms is possible. Probably you have used a timer that displays 1/100th seconds insted of 1/1000 and that could be confusing to calculate the latency (chinese gadget reviews often run into this). So its 100-200ms.Paillasse
S
8

I have a RasPi model B and use mjpg-streamer. The delay is almost unnoticeable running at 12fps 640 x 480. It takes around 10 mins to install and configure. In addition to mjpg-streamer I have also tried Motion and FFMpeg, but both were very laggy.

There is a good webcam tutorial for the Raspberry that you may find helpful.

Stoichiometry answered 14/6, 2013 at 5:27 Comment(4)
You should try GStreamer (which is available for the Pi), it is really faster!Ilmenite
I completely agree with @Val. Now I'm using GStreamer since it uses less CPU. Mjpeg-streamer is only good if webcam supports MJPEG. If you have YUV camera, it will have to decode and encode video on CPU and this causes over 90% of load on the overclocked PiWotton
Is it answer valid for today? Or maybe you can suggest some more modern framework?Lourdeslourie
I believe the link is no longer pointing to the intended page. It's pointing to the website's main page instead of the article.Cartagena
C
0

Use the stream.py in this git repo. We have three functions there.

The run function starts streaming with default port 8001. You can change the default port by passing an integer to that.

The stop function stops streaming.

And finally you can check the status by calling status function.

Conserve answered 16/4, 2019 at 4:40 Comment(0)
R
0

For lower latency, I would recommend using Raspberry pi in wifi-AdHoc mode. After that use the code below to enjoy low latency live streaming:

import picamera
import  pyshine as ps #  pip3 install pyshine==0.0.9
HTML="""
<html>
<head>
<title>PyShine Live Streaming</title>
</head>

<body>
<center><h1> PyShine Live Streaming using OpenCV </h1></center>
<center><img src="stream.mjpg" width='640' height='480' autoplay playsinline></center>
</body>
</html>
"""
def main():
    StreamProps = ps.StreamProps
    StreamProps.set_Page(StreamProps,HTML)
    address = ('192.168.1.1',9000) # Enter your IP address 
    StreamProps.set_Mode(StreamProps,'picamera')    
    with picamera.PiCamera(resolution='640x480', framerate=30) as camera:
        output = ps.StreamOut()
        StreamProps.set_Output(StreamProps,output)
        camera.rotation = 90
        camera.start_recording(output, format='mjpeg')
        try:
            server = ps.Streamer(address, StreamProps)
            print('Server started at','http://'+address[0]+':'+str(address[1]))
            server.serve_forever()
        finally:
            camera.stop_recording()
   
        
if __name__=='__main__':
    main()

More detail can be found in this tutorial

Rattoon answered 16/4, 2021 at 5:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.