0

Is there any advantage of using HLS (HTTP Live Streaming) over HTML5 <video> for sharing large video files? I am using ffmpeg to create chunks and the associated m3u8 manifest file manually on my server for sharing large video files, and use libraries like hls.js for integrating it in my website. Previously I share the video file directly using <video> tag (eg: <video src="/path/to/some_video.mp4">

I know HTML5 video uses HTTP Progressive Download, and the webserver would use moov atom in the video file to serve small progressive chunks. On the other hand, in the case of HLS, I manually create the chunks on the server side so that my browser can request them directly through the m3u8 manifest file. I believe the HTML5 video causes the webserver to spend extra CPU cycles chunking the video using the moov atom on the fly, whereas in the HLS case, it doesn't spend any cycles for chunking and can serve the pre-chunked file on HTTP GET. So I think HLS may reduce CPU workload on the server side when serving video files since the pieces are pre-chunked.

I am not sure if that's true, and I'd like to get some insights into this: using HTML5 video vs HLS for serving video files.

Harsath
  • 133
  • 3
  • 6

1 Answers1

0

It's not really HLS vs HTML5 Video as HLS usually uses HTML5 video.

HLS is a streaming transport protocol - the videos that are streamed to a browser using HLS are then typically assembled into a video file that the browser recognises by a 3rd party Javascript player, like video.js or Shaka etc, and presented to the HTML5 video element in the browser to be played.

The picture is complicated as different browser have different support and some may natively support HLS also.

One of the primary benefits of ABR protocols like HLS is that they allow you serve multiple bit rate versions of each chunk of your video. This allows the client adapt and request different bit rates for each chunk depending on the current network conditions, and the device.

For your use case, if you expect the user to download the complete file in advance then you may be only interested in a single bit rate, but if you are streaming VOD on demand that HLS and DASH are likely that you want to look at. More info on ABR here: https://stackoverflow.com/a/42365034/334402

Mick
  • 24,231
  • 1
  • 54
  • 120
  • Thanks for your answer. I don't want to allow a user to grab my `.mp4` file from the source code's `src` attribute. That's one of the primal reasons why I'm thinking about HLS. I'm streaming over a single bit rate, so ABR isn't my primary concern. HLS makes it difficult for most people to rip off video (most, since a few people go an extra mile of saving a video from m3u8 file). I know there are other techniques like CSRF tokens, right-click disabling, but HLS seems both easier to set up (compared to CSRF) and secure compared to right-click disabling with JS. – Harsath Jan 18 '22 at 02:50