We need to capture a live video stream from WebRTC (or any other capturing mechanism from the client webcam, even if it is not supported on all browsers, but as a PoC).
This live video needs to be handled by a server component (ASP.Net MVC / Web API), I imagine that the code on the server will look like:
[HttpPost] public ActionResult HandleVideoStream(Stream videoStream) { //Handle the live stream } Looking for any keyword or helpful link.
We have already implemented a way to send individual frames using base64 jpg, but this is not useful at all, because there is a huge overhead of the base64 encoding and because we could use any video encoding to send the video more efficiently (send the difference between the frames using VPx -vp8- for example), the required solution needs to capture a video from the webcam of the client and send it live (not recorded) to the server (asp.net) as a stream -or chunks of data representing the new video data-.
Your question is too broad and asking for off-site resources is considered off-topic on stackoverflow. In order to avoid opinion-prone statements I will restrict the answer to general concepts.
Flash/RTMP
WebRTC is not yet available on all browser so the most widely used way of capturing webcam input from a browser currently in use is via a plugin. The most common solution uses the Adobe Flash Player, whether people like it or not. This is due to the H.264 encoding support in recent versions, along with AAC, MP3 etc. for audio.
The streaming is accomplished using the RTMP protocol which was initially designed for Flash communication. The protocol works on TCP and has multiple flavors like RTMPS (RTMP over TLS/SSL for encryption), RTMPT(RTMP encapsulated in HTTP for firewall traversal).
The stream usually uses the FLV container format.
You can easily find open-source projects that use Flash to capture webcam input and stream it to an RTMP server.
On the server-side you have two options:
RTMP server to talk directly to the sending library and read the streamRTMP servers and implement just a client in ASP (you can also transcode the incoming stream on the fly depending on what you're trying to do with your app).WebRTC
With WebRTC you can either:
WebRTC with the server being one of the peers.A possible solution for the second scenario, which I haven't personally tested yet, is offered by Adam Roach:
- Browser retrieves a webpage with javascript in it.
- Browser executes javascript, which:
- Gets a handle to the camera using
getUserMedia,- Creates an
RTCPeerConnection- Calls
createOfferandsetLocalDescriptionon theRTCPeerConnection- Sends an request to the server containing the offer (in
SDPformat)- The server processes the offer
SDPand generates its own answerSDP, which it returns to the browser in its response.- The JavaScript calls
setRemoteDescriptionon theRTCPeerConnectionto start the media flowing.- The server starts receiving
DTLS/SRTPpackets from the browser, which it then does whatever it wants to, up to and including storing in an easily readable format on a local hard drive.
Source
This will use VP8 and Vorbis inside WebM over SRTP (UDP, can also use TCP).
Unless you can implement RTCPeerConnection directly in ASP with a wrapper you'll need a way to forward the stream to your server app.
The PeerConnection API is a powerful feature of WebRTC. It is currently used by the WebRTC version of Google Hangouts. You can read: How does Hangouts use WebRTC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With