Question

I have noticed that youtube and dailymotion have a mechanism in place to be able to "choose" a video quality for you based on your internet connection.For e.g since i have a 1 mbps internet connection , video load at 360p by default.For those with higher internet connection video load at 480p/720p/1024

How does youtube determine which internet connection i have ?

Implementing such a feature definitely reduce bandwidth for the host and enhance the user experience.

I would love a php based solution so that i can try to implement this on my site

Was it helpful?

Solution

Determining the available bandwidth for a web based video player is done client side. If the client (ie the player) thinks it has not sufficient bandwidth to maintain playback at the current bitrate without buffering it requests a lower bitrate rendition to the server (and the other way around). This is a well known mechanism of adaptive bitrate streaming - client bandwidth is checked at startup and at fixed intervals and based on those results the player is able to react to maintain decent playback. PHP being a sever side scripting language cannot be used for this part of the process.

For Youtube flash based player I guess they use their own flavor of action script bandwidth detection. If you use FMS there is a native way to achieve this. Otherwise you need to code it yourself. Here is to give you an idea on how to implement this.

For JavaScript you can have a look here. Based on available internet connection speed you can then make your player to take a decision.

You could consider looking at MPEG DASH that has a JS lib with bandwidth detection built in it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top