Pure Js Stream From Webcamera To Server
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 strea
Solution 1:
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 = newMediaRecorder(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 .
Post a Comment for "Pure Js Stream From Webcamera To Server"