Skip to content

Commit 327fa81

Browse files
committed
Update to work with SASH 0.2
1 parent 3ba0ac3 commit 327fa81

File tree

4 files changed

+70
-31
lines changed

4 files changed

+70
-31
lines changed

0.2.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"sash_version" : 2,
3+
"presentation_duration": 300,
4+
"video" : [
5+
{
6+
"mime_type" : "video/mp4",
7+
"segment_template" : {
8+
"duration": 1.960,
9+
"init": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$rendition$init.mp4",
10+
"media": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$rendition$_00000000$number$.mp4",
11+
"start_number": 1,
12+
"end_number" : 9
13+
},
14+
"renditions" : {
15+
"bbb-video-540p-2000k" : {
16+
"bandwidth": 800000,
17+
"codecs": "avc1.4d401e",
18+
"height": 480,
19+
"width": 852
20+
}
21+
}
22+
}
23+
],
24+
"audio": [
25+
{
26+
"mime_type" : "video/mp4",
27+
"segment_template": {
28+
"duration": 1.996,
29+
"init": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$rendition$init.mp4",
30+
"media": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$rendition$_00000000$number$.mp4",
31+
"start_number": 1,
32+
"end_number": 9
33+
},
34+
"renditions": {
35+
"bbb-audio-64k" : {
36+
"bandwidth": 64000,
37+
"codecs": "mp4a.40.2"
38+
}
39+
}
40+
}
41+
]
42+
}

manifest.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
"mime_type" : "video/mp4",
77
"segment_template" : {
88
"duration": 1.960,
9-
"init": "http://s3-us-west-2.amazonaws.com/mpag-sash/media/tos/dash/$representation$/init.m4f",
10-
"media": "http://s3-us-west-2.amazonaws.com/mpag-sash/media/tos/dash/$representation$/segment$number$.m4f",
9+
"init": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$representation$init.mp4",
10+
"media": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$representation$_00000000$number$.mp4",
1111
"start_number": 1,
12-
"end_number" : 368
12+
"end_number" : 9
1313
},
1414
"representations" : {
15-
"video-480p" : {
16-
"bandwidth": 800000,
17-
"codecs": "avc1.4d401e",
18-
"height": 480,
19-
"width": 852
15+
"bbb-video-540p-2000k" : {
16+
"bandwidth": 2000000,
17+
"codecs": "avc1.4d401f",
18+
"height": 540,
19+
"width": 960
2020
}
2121
}
2222
},
@@ -25,13 +25,13 @@
2525
"mime_type" : "audio/mp4",
2626
"segment_template": {
2727
"duration": 1.996,
28-
"init": "http://s3-us-west-2.amazonaws.com/mpag-sash/media/tos/dash/$representation$/init.m4f",
29-
"media": "http://s3-us-west-2.amazonaws.com/mpag-sash/media/tos/dash/$representation$/segment$number$.m4f",
28+
"init": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$representation$init.mp4",
29+
"media": "https://d1czxfd0hfd9km.cloudfront.net/outputs/bbb/mediaconvert/dash/$representation$_00000000$number$.mp4",
3030
"start_number": 1,
31-
"end_number": 368
31+
"end_number": 9
3232
},
3333
"representations": {
34-
"audio-64k" : {
34+
"bbb-audio-64k" : {
3535
"bandwidth": 64000,
3636
"codecs": "mp4a.40.2"
3737
}

sash-player.html

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
<title>SASH reference player</title>
55
</head>
66
<body>
7-
<video id="player" controls="true"></video>
7+
<video id="player" controls muted></video>
88
<script type="text/javascript" src="sash.js"></script>
9-
<p><a href="http://github.com/sfvideo/sash">Part of the Simple Adaptive Streaming over HTTP project (SASH)</a></p>
10-
<p>Media: <a href="https://mango.blender.org/">&quot;Tears of Steel</a>&quot;</p>
11-
<p>Encoding: <a href="https://zencoder.com">Brightcove Zencoder</a></p>
9+
<p>A demonstration of <a href="http://github.com/demuxed/sash">Simple Adaptive Streaming over HTTP project (SASH)</a></p>
1210
</body>
1311
</html>

sash.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
}
1616

1717
// TODO: 1) Limit the number of the buffers we hold in memory if MSE is slow to consume them
18-
// 2) Stop downloading segments when we've got a sensible numbers buffered
19-
// 3) Support scrubbing
18+
// 2) Stop downloading segments when we've got a sensible number buffered (Or even better a configurable duration...)
19+
// 3) Support scrubbing to un-buffered points in the content
2020

2121
// Track prototype
2222
function Track(mediaSource, codecString, segments) {
@@ -73,20 +73,19 @@
7373
var mediaSource = new MediaSource();
7474
var player = document.querySelector('#player');
7575

76-
// TODO: This is a bad implementation of a SASH manifest reader. Clean it up & modularise.
77-
// TODO: Since this will become a module, also using jquery is a little lazy
78-
$.getJSON( "manifest.json", function( manifest ) {
79-
for (i = 0; i < manifest.adaptation_sets.length; i++) {
80-
for (j = 0; j < Object.keys(manifest.adaptation_sets[i].representations).length; j++) {
81-
repid = Object.keys(manifest.adaptation_sets[i].representations)[j];
82-
var codecString = manifest.adaptation_sets[i].mime_type + '; codecs="' + manifest.adaptation_sets[i].representations[repid].codecs + '"';
83-
var segments = [manifest.adaptation_sets[i].segment_template.init.replace('$representation$', repid)];
84-
for (k = manifest.adaptation_sets[i].segment_template.start_number; k <= manifest.adaptation_sets[i].segment_template.end_number; k++) {
85-
segments.push(manifest.adaptation_sets[i].segment_template.media.replace('$representation$', repid).replace('$number$', k));
86-
}
87-
new Track(mediaSource, codecString, segments);
76+
$.getJSON( "0.2.json", function( manifest ) {
77+
78+
// Grab the first Audio and Video renditions we find, and push them onto MSE
79+
['video', 'audio'].forEach(function(element) {
80+
firstRenditionName = Object.keys(manifest[element][0].renditions)[0];
81+
firstRendition = manifest[element][0].renditions[firstRenditionName];
82+
var codecString = manifest[element][0].mime_type + '; codecs="' + firstRendition.codecs + '"';
83+
var segments = [manifest[element][0].segment_template.init.replace('$rendition$', firstRenditionName)];
84+
for (k = manifest[element][0].segment_template.start_number; k <= manifest[element][0].segment_template.end_number; k++) {
85+
segments.push(manifest[element][0].segment_template.media.replace('$rendition$', firstRenditionName).replace('$number$', k));
8886
}
89-
}
87+
new Track(mediaSource, codecString, segments);
88+
});
9089

9190
// Only init MSE once the manifest is loaded.
9291
player.src = window.URL.createObjectURL(mediaSource);

0 commit comments

Comments
 (0)