Adaptative bitrate streaming (DASH, HLS...) VS Node Streams

Viewed 577

In Node.js, streams can be used easily to deliver a media content by chunks (as a video for example).

It is also possible to use an adaptative bitrate streaming method like DASH or Http Live Streaming by breaking down segments of the media to send. It looks like it is recommended to implement this second method over the first one in the case of a videos delivery streaming platform.

I would like to know why and what's the difference in terms of benefits and disadvantages to implement an adaptative bitrate streaming method instead of using Node.js native streams for a video streaming app ?

EDIT : Example of using Node.js streams to deliver a media content by chunks :

var videoStream = fs.createReadStream(path, { start, end });
res.writeHead(206, {
  "Content-Range": `bytes ${start}-${end}/${size}`,
  "Accept-Ranges": "bytes"
});
videoStream.pipe(res);
1 Answers

There is a bit of confusion in the question. The streams in Node.js are just a structure for easily sending streams of data around your application. They're not directly relevant.

I suspect what you're getting at is the difference between regular HTTP progressive streaming (such as piping video data to a response stream to a client) vs. a segmented streaming protocol like DASH or HLS.

Indeed, you can send an adaptive bitrate stream over a regular HTTP progressive stream as well. Nothing prevents you from changing the bitrate on the fly.

The reason folks use DASH and HLS is that they allow re-use of regular static file/blob/object-based CDNs. They don't require specialized server software to stream. Any HTTP server works.

Even if you don't need to use existing CDNs, you might as well stick with DASH/HLS for the benefit of there being client support most everywhere now. You won't have to write your own client to track metrics to decide when to switch bitrates. Using DASH/HLS allows you to be compatible with existing devices, often with writing no additional code at all.

Related