Is it possible to capture stream from webcamera(in front end) and stream it to server via hls or rtmp with pure js(no flash).
And if there are another protocol which let send stream as stream(unlike hls), will be prefered.
I found solution.
There is no (yet) any way to "convert" stream received from navigator.getUserMedia()
to rtmp
in front-end.
But we can use MediaRecorder Api.
In client Side
const stream = await navigator.getUserMedia(options)
const recorder = new MediaRecorder(stream)
recorder.ondataavailable = (e) => { socket.emit('binaryData',e.data) }
recorder(start)
In backend
const ffmpegProcess = spawn('ffmpeg', ffmpegCommans)
socket.on('binaryData', (data) => {
ffmpegProcess.stdin.write(params.data)
})
FFmpeg will convert vp8 video stream to hls/rtmp/rtsp or whatever.
In this way we can get video stream with latency 3(average) second .
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