Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add video quality peak limiter #43

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions player/custom-quality-labels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 4K

Enable users to watch 4K high-definition content

### Tags

- TestTag
Empty file.
6 changes: 6 additions & 0 deletions player/custom-quality-labels/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions player/custom-quality-labels/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/bitmovinplayer.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/bitmovinplayer-ui.js"></script>
<script type="text/javascript"
src="//bitmovin-a.akamaihd.net/bitmovin-analytics/stable/1/bitmovinanalytics.min.js"></script>

<div class="description">
<p>
This demo showcases how to customize video quality labels. You can use this to A/B test labels that make most sense to your users.
</p>
</div>

<div class="row">
<div class="col-lg-6 player-col">
<div id="player" class="tv-frame">
<div id="player-container"></div>
</div>
<br/>
<ul>
<li>Map bitrates to actual values</li>
<li>Map bitrates to low, medium, high, premium labels</li>
<li>Map higher quality labels for HD, UHD, 4K etc.</li>
</ul>
</div>
<div class="col-lg-6 code-col">
<div class="setup-code">
${code:setup.js}
</div>
</div>
</div>
16 changes: 16 additions & 0 deletions player/custom-quality-labels/info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: Custom Quality Labels
description: Customize video quality labels
long_description: To be defined.

executable:
executable: true
indexfile: index.html

code:
show_code: true
language: js
files:
- setup.js

tags:
- To be defined
59 changes: 59 additions & 0 deletions player/custom-quality-labels/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var humanizeBitrate = function(bitrate){
var mbit = bitrate / 1000000;
var rounded = mbit < 3 ? Math.round(mbit * 10) / 10 : Math.round(mbit);
return rounded + 'Mbit';
};

var getQualityLabels = function (data) {
if (data.height <= 144) {
return '144p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 240) {
return '240p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 360) {
return '360p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 480) {
return 'SD 480p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 720) {
return 'HD 720p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 1080) {
return 'HD 1080p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 1440) {
return 'HD 1440p (' + humanizeBitrate(data.bitrate) + ')';
} else if (data.height <= 2160) {
return '4K 2160p (' + humanizeBitrate(data.bitrate) + ')';
}
};

var conf = {
key: '29ba4a30-8b5e-4336-a7dd-c94ff3b25f30',
analytics: {
key: '45adcf9b-8f7c-4e28-91c5-50ba3d442cd4',
videoId: 'custom-quality-labels'
},
playback: {
muted: true
}
};

var source = {
hls: 'https://cdn.bitmovin.com/content/demos/4k/38e843e0-1998-11e9-8a92-c734cd79b4dc/manifest.m3u8',
poster: 'https://bitmovin-a.akamaihd.net/content/sintel/poster.png',
labeling: {
hls: {
qualities: getQualityLabels
}
}
};

var playerContainer = document.getElementById('player-container');
var player = new bitmovin.player.Player(playerContainer, conf);

function loadPlayer() {
player.load(source).then(function() {
player.setVideoQuality('1600_50128000');
});
}

$(document).ready(function () {
loadPlayer();
});
30 changes: 30 additions & 0 deletions player/custom-quality-labels/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var getQualityLabels = function (data) {
if (data.height <= 1440) {
return '1440p HD';
} else if (data.height <= 2160) {
return '2160p 4K';
}
}

var conf = {
key: '<YOUR PLAYER KEY>'
};

var source = {
dash: 'https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd',
hls: 'https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
poster: 'https://bitmovin-a.akamaihd.net/content/sintel/poster.png',
labeling: {
dash: {
qualities: getQualityLabels
},
hls: {
qualities: getQualityLabels
}
}
};

var playerContainer = document.getElementById('player-container');
var player = new bitmovin.player.Player(playerContainer, conf);

player.load(source);