使用HTML5和JavaScript更改视频质量

时间:2016-04-24 12:18:01

标签: javascript html5 video

我正在使用带有ISM清单的HTML5视频播放器http://html5-ninja.com/preview/index/5 http://playready.directtaps.net/smoothstreaming/。 在清单文件中有质量级别:

sub DoSearch {
    my $currNode = shift;
    my $currentDir = opendir (my $dirHandler, $currNode->rootDirectory) or die $!;

    while (my $node = readdir($dirHandler)) {
        if ($node eq '.' or $node eq '..') {
            next;
        }

        print "File: " . $node . "\n" if -f $node;
        print "Directory " . $node . "\n" if -d $node;
   }

   closedir($dirHandler);
}

如何使用JavaScript更改视频播放的质量?我不知道该怎么做。我也很高兴任何质量改变的工作实例。

2 个答案:

答案 0 :(得分:0)

根据https://www.h3xed.com/web-and-internet/how-youtube-determines-what-video-quality-to-play,至少在YouTube上,根据屏幕上的视频尺寸和与来源的连接质量自动选择质量。

答案 1 :(得分:0)

The way Adaptive Bit Rate streaming works is that the server provides a manifest with multiple different bit rates streams and the client selects the highest one it can based on the current network conditions and the capability of the devices.

The key point here is that it is the client that selects the bit rate.

In some clients you can override this manually (e.g. in YouTube under the settings button while watching a video).

The player you have linked does not appear to have an option to select the bit rate via Javascript.

If you take a look at the dashjs player (http://cdn.dashjs.org/latest/jsdoc/index.html) you can see it has some methods that allow you control the bit rate switching, for example (at http://cdn.dashjs.org/latest/jsdoc/module-MediaPlayer.html):

  • setMaxAllowedBitrateFor(type, value)

It might be useful to play around with this to see if it meets your needs.