-
Notifications
You must be signed in to change notification settings - Fork 0
/
testold.html
97 lines (88 loc) · 2.29 KB
/
testold.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<video controls></video>
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.3.10/seedrandom.min.js></script>
<script>
Math.seedrandom('hello.');
var buffer = null;;
var sourceBuffer;
var video = document.querySelector('video');
var mediaSource;
var fuzzed;
var i = 0;
var val = 0;
var crashes = [];
function fuzz() {
var buf = buffer.slice(0);
var view = new DataView(buf);
i++;
val = 0;
view.setUint8(i, val);
return buf;
}
function setup() {
if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
mediaSource = new MediaSource;
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener('sourceopen', sourceOpen);
} else {
console.error('Unsupported MIME type or codec: ', mimeCodec);
}
}
var assetURL = 'out.mp4';
// ./mp4info frag_bunny.mp4 | grep Codec
var mimeCodec = 'video/mp4; codecs="avc1.42c01e"';
setup();
function sourceOpen (_) {
var mediaSource = this;
mediaSource.removeEventListener('sourceopen', sourceOpen);
sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
if(buffer === null) {
fetchAB(assetURL, function (buf) {
sourceBuffer.addEventListener('updateend', function (_) {
if(sourceBuffer.buffered.length == 0) {
try {
fuzzed = fuzz();
sourceBuffer.appendBuffer(fuzzed);
} catch(e) {
console.log("Crashed on " + i + " to " + val);
crashes.push([i, val]);
if(crashes.length < 10) {
setTimeout(setup, 1000);
} else {
document.body.innerHTML = "<pre>" + JSON.stringify(crashes, undefined, 2) + "</pre>";
}
}
} else {
try {
mediaSource.endOfStream();
//success();
} catch(e) {
//failure();
}
sourceBuffer.remove(0, 1000);
}
//video.play();
});
buffer = buf;
fuzzed = buf;
sourceBuffer.appendBuffer(buf);
});
}
};
function fetchAB (url, cb) {
var xhr = new XMLHttpRequest;
xhr.open('get', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
cb(xhr.response);
};
xhr.send();
};
</script>
</body>
</html>