Reputation: 189
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.
Upvotes: 14
Views: 57098
Reputation: 1283
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
Upvotes: 0
Reputation: 143
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.
Upvotes: 0
Reputation: 96
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.
Upvotes: 8