Hls.js: [Question] Can i load multiple chunk in same time?

Created on 17 Mar 2018  Â·  11Comments  Â·  Source: video-dev/hls.js

@I see the video on facebook load very fast. They video load more than 1 chunk in same time.
I see the video on webtorrent.io, they load video multiple chunk and very fast, like facebook video.
Are HLS.js can load multiple chunk in same time?

//my question for VOD file only.

Question Wontfix

Most helpful comment

Hello tchakabam,
Thank you for your reply.
I have resolved this issue, now my player can load 4 chunk in same time. Like webtorrent.io, this make the video load faster. https://i.imgur.com/zdzwb1c.png

how did you achieve this? thanks

All 11 comments

if there are separate chunks for audio and video, yes Hls.js does do that concurrently. however it only makes sense to load data in the order in which it can be consumed, and also making several requests to the same host (as usually chunks are on the same host) will usually use the same route, and thus doing those requests concurrently does not necessarily optimize your bandwidth.

there is in theory a possibility that owning several connections on the same route may optimize chances to get a larger share of bandwidth from the total capacity of the channel. but that is making assumptions about the routers' behaviours, (and TCP), and also it means that you are using one connection per requests. when making XHR or using Fetch API we can not control through what connection(s) these requests go, they may all share one connection, or depend on browser implementation and configured limits of connections etc.

therefore it is better imho to keep it "simple" in that sense, and to just load the data first that you need first, and also that will make sure that loading the other data doesn't create congestion on the early data you need. hope it's understandable how that makes sense :)

Hello tchakabam,
Thank you for reply my question.
I have split video intro multiple .ts chunk, and i upload this chunks in multiple hosting - with multiple domain.
Now i have one video in multiple host. This is best if i can load multiple chunk in same time.
Please teach me how i can load multiple chunk in same time with hls.js?

Hey, you're welcome.

I don't think you will see any noticeable gain from spreading your resources on multiple hosts either, this is all just theory.

But it's always an interesting topic again.

Having concurrent loading of segments enabled for the same stream type (audio or video) would be a demanding feature to implement. The stream-controller currently is built very much in a "walk-forward" way scheduling and processing one segment after the other. Of course it would be nice to make that more flexible, but on the other in real-life the gains will be hardly noticeable.

To answer your question: I can not "teach" you that, it would be a feature to implement :)

What is it that you want to optimize? Start-up latency? Or maximum bandwidth throughput?

The start-up latency depends on loading specific data, and thus loading more data concurrently is not going to make anything faster unfortunately.

More important in fact here is the size of the chunks that you choose when creating your HLS content.

Apple used to recommend 10 seconds, but if you want to have fast startup, 2 seconds is much better and actually works very well in my experience.

Hls.js has various settings to parametrize buffering behaviour, those can have an actual impact on your performance.

But first you should try to understand what you want to optimize for, and make an educated decision on the segment length. Shorter segments is for fast startup and switching, larger segments will provide better over-all throughput efficiency on your channel, and enforce a larger buffer to the player. But that can also be setup by Hls.js to ensure that the buffer needs to be a certain size before playing, as to make sure we can work out bandwidth variations.

So I would always rather go for shorter segments (TCP transfer for 2 seconds large segments is still very efficient) and setup the settings in such a way that still provides robustness on the playback side.

Hope that helps a little bit with that :+1:

If you want to work on concurrent loading of segments, or would like to have that, I would suggest you open a proper feature ticket here.

Hello tchakabam,
I have example.

  • You have 100 video + 10 vps.
  • 10 vps have network 100mbit/s
  • You upload 10 video into per 1 vps, this is ok. But if have 1 or 2 video has much more realtime online than others video. That mean 1 or 2 vps of you will get overload.

But if you split 100 video into 1000 chunk, and upload random 100 chunk per 1 vps. That mean you can use all resource (cpu, ram, network) of 10 vps.

This so good, and can good more if we can load multiple chunk (with multiple source) in same time.

I have an project. You can see example In here: http://rearik.blog/watch?v=5ab27343c798f
Now i using jwplayer for play m3u8, but i want change to videojs-hls, because videojs is opensource.

I hope i can find a solution with hls.js

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@okgame sorry i missed that last message of yours. i am not sure your example translates to anything i can see would make sense in "real life". assuming by VPS you mean something like a hosted service with a given bandwidth at disposition. the short answer is: you would solve that at the CDN level. what you mean basically is having multiple origins for the data? however when you distribute video, at scale (with a lot of users) you never actually serve every single chunk directly to the player. you use caching through some sort of CDN that offers POPs (points of proximity) to users, as to optimize bandwidth and latency with regard to their geophraphical location in the network. now, if you decide that you need to scale-out your origins because there will be so much bandwidth needed at the origin (maybe with many live videos at the same time) this is just a matter of load-balancing that you'd need to setup in the connections between the CDN and your origin servers, for example using DNS, or by using a push-mechanism to deliver data to the CDN before it even gets requested. that all depends on the choices and architecture of your streaming server system. but it's really none todo with loading several segments at the time from the player.

in short: wether your player loads several segments at the time or not, doesn't solve any problems with server-side bandwidth.

Hello tchakabam,
Thank you for your reply.
I have resolved this issue, now my player can load 4 chunk in same time. Like webtorrent.io, this make the video load faster. https://i.imgur.com/zdzwb1c.png

Hello tchakabam,
Thank you for your reply.
I have resolved this issue, now my player can load 4 chunk in same time. Like webtorrent.io, this make the video load faster. https://i.imgur.com/zdzwb1c.png

how did you achieve this? thanks

@okgame i would also be interested in how you did archive this.

兄弟求修改hls.js的办法。。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bharathsn0812 picture bharathsn0812  Â·  4Comments

sbrez picture sbrez  Â·  3Comments

GeorgySerga picture GeorgySerga  Â·  3Comments

krsvital picture krsvital  Â·  3Comments

ronag picture ronag  Â·  4Comments