Lee Melbourne
Lee Melbourne

Reputation: 417

How To Re-Stream Web Camera Via Server

I am designing a solution which will allow video from a webcam attached to a Raspberry Pi to be streamed to my server in AWS and then re-streamed to a browser accessing a website on the AWS Server. Many Pis would be involved and a user would trigger and access the feed coming from their own Pi on demand.

This is unfamiliar territory for me so I dont really know where to start and I am seeking advice on the best architecture.

So far I am considering a process (ideally python) on each Pi which would open a web socket connection to the server. The server would track each socket in terms of the user account it related to. A user would then connect to the server, trigger a signal over the web socket to turn on their own Pi video feed, and the video feed would be sent to my server. They idea is they should then see the video feed via a URL on my site NOT via a URL on the Pi - this would resolve any NAT access issues.

How can I send the video feed from each Pi webcam to the server, such that it appears the live feed is coming from the server itself?

It is essentially the same thing requested here which did not receive an answer.

Upvotes: 0

Views: 1559

Answers (2)

spippulus
spippulus

Reputation: 21

For your purposes the easiest and most powerful tool is UV4L as mentioned in the comments. Apart from its native p2p capabilities, I would also consider this for interconnecting many peers: https://www.linux-projects.org/rpi-videoconference-demo-os/.

That essentially is a ready-to-use OS image for Raspberry Pi providing a audio/video conference room (thanks to Janus SFU) at boot to which many Raspberry Pi's (including the one running the OS) with camera, microphone, display and speakers attached or PCs, smart phones, and so on can publish/subscribe their/other's audio or video streams. The Raspberry Pi running the OS can eventually decide to connect to any video room on Internet like the above in the above link, not just the "local" one. No browser is required on the Rpi side as UV4L uses all the hardware directly and has native support for WebRTC (it even supports H264 hardware encoding/decoding). Both Janus Gateway and UV4L can be set up with any given list of STUN/TURN servers and have been used successfully with AWS instances too.

There is a built-in web page in UV4L making all the above possible with a few mouse clicks. However, with the UV4L RESTFul API (and with the help of the panel for testing this API) you can write/customize your own web application for specific purposes (e.g. create a private, password protected room with a given number of publishers or subscribers matching the requirements in your case)

Upvotes: 2

Brad
Brad

Reputation: 163272

Skip the part where you stream through your server, and just use WebRTC.

It's peer-to-peer, works in-browser, has automatic codec negotiation, NAT traversal, everything you need. All you need to host then is a signalling server and a TURN server for when both peers are firewalled.

Upvotes: 1

Related Questions