10
votes

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 somehow impossible but I managed to cut delay down to 20ms.

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. - Tim Hoffman
I did it and stream was realy slow. I will use ordinary FPV and make OSC (on screen display) by myself using Pi - Klemen
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. - Zoltán Hajdú

3 Answers

8
votes

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.

0
votes

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.

0
votes

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