I have a Node.js process which outputs a video stream into my Node.js app.
On the client end, there is a <video>
tag. I would like to stream the video from Node.js into the src
attribute of the video tag. My previous experience tells me that we must use the blob
object for this. However, I'm not a hundred percent certain how and why I would use it.
Another possible solution I'm thinking of is to create some sort of a temporary file on my server, then write the stream to that file, then serve that file as the source for the video. However, that doesn't seem intuitive. I was wondering, then, if there is a more established solution for an issue like this.
m3u8 format is commonly used for streaming. Video streaming/transcoding is a resource intensive thing. I would suggest you to use third party service to do so, if you have that option.
Probably you might want to look at the following options:
BinaryJS. It's bidrectional realtime binary data transfer tool based on websockets.
JSMpeg stream-server (in case of capturing) from Phoboslab guys. All you need to do is start ffmpeg
and point it to the domain and port where the nodejs script is running.
More info you can find here.
Pipe a stream directly. Good answer is posted here. In few words you just need to specify Accept-Ranges
, Content-Range
, Content-Length
and Content-Type
headers, then create relevant Read stream (with start
and end
options) and pipe it to the response
object.
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