Stream recorded audio from browser to server - node.js

I would like to live stream recorded audio from the browser to the server and play it. The server will end up being a embedded device that plays these audio streams.
So far I've successfully recorded audio and encoded it into a WAVE file and play it on the browser using the web audio API and following this tutorial.
Now I have a stream of .WAV encoded blobs. I tried finding ways to stream these to a nodejs backend with a web socket connection and play them using a npm module. But I haven't had any luck.
Does anyone know of any resources or modules I should follow? Maybe I should try a different approach? The audio needs to be played relatively quickly on the server since recording on the browser.

I'm doing this currently with some software that allows for streaming to internet radio servers via your web browser.
I use the WebAudio API along with getUserMedia to get live PCM audio data from the sound device. From there, I convert this data from 32-bit float to 16, 12, or 8 bit data depending on the amount of bandwidth available. This converted int samples are written to a stream setup with BinaryJS which wraps streams on both the Node.js and the client. As a bonus with BinaryJS, you can have as many streams open as you want, so I use a second stream over the same WebSocket connection for control data.
http://demo.audiopump.co:3000/

Related

How to play RTSP stream from ip video camera and NVR on user web page

I want to play RTSP stream from ip video cameras (MP4, H264) on my intranet web page, I use React. I have 12 cameras and NVR.
I did not find a way to do this without an intermediate server (Webrtc is not suitable), that spends resources on transcoding h264 stream to the mjpeg.
If I set a high resolution and quality of the stream, then a lot of resources are spent on transcoding, and most importantly, the streaming of mjpeg images takes a lot of traffic.
Is there a way or solution to stream from the ip camera directly to the web page so that the decoding is on the user's webbrowser side.
This will free the intermediate server from a heavy load for big streams.
It is necessary that the playback work on mobile phones.
Thanks for the answer.
There is no way to stream RTSP camera's H264 video directly to web browser.
But cameras support outputting still jpeg images - you can create a webpage that will display such an image from a camera every 200ms or so.
If you are not happy with the above solution, you must use a media server in between, which will pull RTSP stream from the camera and will convert it to some protocol that browser understands. You are mistaken in one thing: no video transcoding is involved. I don't know why WebRTC is not an option for you, but most media servers will offer 4 types of output:
Low latency:
WebRTC
Websockets to MSE
High latency:
HLS
MPEG-Dash
All these methods do NOT require transcoding of your original H264 video, encoded by RTSP camera/NVR. Some media servers you can use: Unreal Media Server, Wowza, Janus.
Live demo: http://www.umediaserver.net/umediaserver/demos.html
No browser has native RTSP support, so if you want decoding to happen on the end user side, then you'll have to write your own custom web player.
You can start by looking at the open-source solution like this one:
git://github.com/Streamedian/html5_rtsp_player.git
It works on PC and Android, but didn't work with iPhone for me (but you can try it for yourself https://streamedian.com/demonstration/ maybe it's just my issue), but maybe you can find better alternative or fork it and make it work on all devices.
It still requires a middle-man proxy server though because it uses a websocket tech to work, but since it doesn't do any video converting or decoding, it don't suppose to take any resources at all.

How to play a live video in the browser?

I need to get live video from a device. I have to play the video on the browser. live video can be received as RTP or UDP.
Since there is no support for VLC, I published the video by getting it via RTP with FFMPEG and creating a web server with Nginx.
But later I realized that it is recording video tracks to disk. This is a situation I don't want.
Is there any other way to do this?
Not with RTP or UDP, no, there is no way. You must use WebRTC, or an HTTP based method like HLS or DASH.

Live streaming from UWP to Linux/Python Server

I have an UWP app that capture a live video stream (webcam), encodes it in h264, and sends it through a TCP socket (in a local network, I need high performance) to a Linux device.
Is there a way to do this? I need the video not for playing it but for extract single frames. I could do that with opencv but it requires a local video file, instead I'm using a live stream.
I would send photos instead of a video stream if the time needed for capture one was acceptable, but it requires about 250 ms.
Is RTP required? Does UWP (windows) provides a way to achive this?
Thank you
P.S.: The UWP app runs in Hololens.
You can use WebRTC to transmit live video from the HoloLens easily to any target. That's probably the easiest way to do it without going really low level.
For an introduction just grab this repo and try the sample app which runs perfectly on the HoloLens https://github.com/webrtc-uwp/PeerCC/tree/e95f231e1dc9c248ca2ffa040276b8a1265da145/Client

RTP stream with bareSIP

my current setup involves streaming from a GoPro to a linux box, and I managed to get bareSIP running on the box to stream the video locally with the 'v' command. However, there's no documentation or commands to configure an RTP broadcasting stream. Would anyone have any insight into publishing an RTP/RTSP output stream for other users to view on their devices?
I've used Unreal Streaming Media components and found them to be very good. They are lightweight and fast yet very powerful.
Using Unreal components you could install the stream forwarder on your laptop, point it at the RTSP stream and tell it to forward to the Distribution server application.
This app can host thousands of connections (supposedly) and last I looked you didn't need a license if you have 3 or fewer sources. The stream can be viewd via their own small player app, via a web player such as jPlayer or via VLC etc.
I've been pretty happy with this before - it saved me from having to use the Live555 streaming mess.
Good Luck!

WebRTC Video streaming on NodeJS

I am trying to build a Security Camera.
However, I do not want to do something like Port Forwarding to enable streaming. Nor do I want to implement a 3rd party Cloud based Streaming service like Wowza.
Under these conditions, the only way I could find was to implement WebRTC MediaStream on NodeJS
The WebRTC implementations on NodeJS are missing the MediaStream package.
Also the MediaStream package relies heavily on built in browser code to set up and stream audio & video.
How can I do seamless audio video streaming using NodeJS?
Is it even possible? Can NodeJS (a single threaded model) do something as computationally intensive as video transcoding?
This is certainly doable. I read a while back about a webRTC connected drone (https://tech.ipcortex.co.uk/blog/keevioeye) and there's the webRTC connected RC car (http://www.instructables.com/id/WebRTC-Creeper-Drone-Browser-Controlled-RC-Car/). To build it from scratch you would probably need a pico motherboard with Linux Chromium installed to handle the webRTC negotiation to the server receiving the stream.
For server side MediaStream recording, transcoding and even motion detection and facial recognition I'd use the open source Kurento project which has both Java and nodeJS libraries.

Resources