-
Notifications
You must be signed in to change notification settings - Fork 356
/
index-debug.html
407 lines (352 loc) · 14.6 KB
/
index-debug.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCType html>
<!--
/*********************************************************
* LICENSE: LICENSE-Free_CN.MD is CYL_Free-1.0
*
* Author: Numberwolf - ChangYanlong
* QQ: 531365872
* QQ Group:925466059
* Wechat: numberwolf11
* Discord: numberwolf#8694
* E-Mail: [email protected]
* Github: https://github.com/numberwolf/h265web.js
*
* 作者: 小老虎(Numberwolf)(常炎隆)
* QQ: 531365872
* QQ群: 531365872
* 微信: numberwolf11
* Discord: numberwolf#8694
* 邮箱: [email protected]
* 博客: https://www.jianshu.com/u/9c09c1e00fd1
* Github: https://github.com/numberwolf/h265web.js
*
**********************************************************/
-->
<html>
<head>
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<meta charset="utf-8">
<title>h265webjs - https://github.com/numberwolf/h265web.js</title>
<meta charset="utf-8" name="author" content="ChangYanlong">
<meta charset="utf-8" name="email" content="[email protected]">
<meta charset="utf-8" name="discord" content="numberwolf#8694">
<meta charset="utf-8" name="github" content="https://github.com/numberwolf/h265web.js">
<script src="dist/missile.js"></script>
<script src="dist/h265webjs-v20221106.js"></script>
<!--<script src="dist-multi-thread/missile-multi-thread.js"></script>
<script src="dist-multi-thread/h265webjs-v20221106.js"></script>-->
<style>
</style>
</head>
<body>
<div style="width:1190px;background-color: #e9e9e9;">
<div style="width:100%; height:20px; background-color:blue; color:white;">
Player Area
</div>
<div style="width:100%;height:360px;overflow:hidden;">
<div id="glplayer" style="width: 640px; height: 360px; background-color: #c9c9c9;float:left">
</div>
<div style="width: 550px; height: 360px; float:left; background-color:black; overflow:hidden;">
<div style="width:100%; height:25px; background-color:blue; color:white;">
1. Input Play URL (Editable)
</div>
<!-- <input id="url-input" style="width:100%; height: 20px; background-color: rgba(30,31,20,1); color:rgba(240,181,53,1);" value="http://127.0.0.1/live/test.flv"> -->
<input id="url-input" style="width:100%; height: 20px; background-color: rgba(30,31,20,1); color:rgba(240,181,53,1);" value="example_normal/hevc_test_moov_set_head_16s.mp4">
<!--<input id="url-input" style="width:100%; height: 20px; background-color: rgba(30,31,20,1); color:rgba(240,181,53,1);" value="http://flv.vaiwan.com/live/test.live.flv">-->
</input>
<div style="width:100%; height:25px; background-color:blue; color:white;">
2. Input Player Config (Editable)
</div>
<textarea id="config-input" style="width:100%; height: 280px; background-color: rgba(30,31,20,1); color:rgba(240,181,53,1);">
{
"player": "glplayer",
"width": 640,
"height": 360,
"token" : "base64:QXV0aG9yOmNoYW5neWFubG9uZ3xudW1iZXJ3b2xmLEdpdGh1YjpodHRwczovL2dpdGh1Yi5jb20vbnVtYmVyd29sZixFbWFpbDpwb3JzY2hlZ3QyM0Bmb3htYWlsLmNvbSxRUTo1MzEzNjU4NzIsSG9tZVBhZ2U6aHR0cDovL3h2aWRlby52aWRlbyxEaXNjb3JkOm51bWJlcndvbGYjODY5NCx3ZWNoYXI6bnVtYmVyd29sZjExLEJlaWppbmcsV29ya0luOkJhaWR1",
"extInfo" : {
"probeSize" : 8192,
"ignoreAudio" : 0,
"coreProbePart" : 0.1,
"autoPlay" : false,
"cacheLength" : 50,
"rawFps": 24
}
}
</textarea>
</div>
</div>
<hr>
<div style="width:100%;height: 200px; overflow: hidden">
<div style="width:360px;height:200px;float:left;">
<div style="width:100%; height:20px; background-color:blue; color:white;">
SnapShot
</div>
<canvas id="snapshot-canvas" style="width: 360px; height: 180px; background-color: #000000;">
</canvas>
</div>
<div style="width:830px;height:200px;background-color:black;float:left;">
<div style="width:100%; height:20px; background-color:blue; color:white;">
Event Log
</div>
<div style="width:100%;height:170px;overflow: hidden;">
<textarea disabled="disabled" id="logger" style="width: 300px; height: 170px; background-color: #000000; color:white; float:left">
events
--------------------</textarea>
<textarea disabled="disabled" id="logger-cache" style="width: 250px; height: 170px; background-color: #000000; color:white;float:left">
cache log</textarea>
<textarea disabled="disabled" id="logger-pts" style="width: 250px; height: 170px; background-color: #000000; color:white; float:left">
pts log</textarea>
</div>
</div>
</div>
<hr>
<button style="background-color:blue;color:white;" onclick="installPlayer()">1.Install</button>
<button style="background-color:red;" onclick="releasePlayer()">2.Release</button>
|
<button onclick="playPausePlayer()" id="play-button" disabled>1.Play/Pause</button>
<button onclick="seekPlayer()">2.Seek To 5s</button>
<button onclick="mutePlayer()">3.Mute(Volume 0.0)</button>
<button onclick="unmutePlayer()">4.Volume To 1.0</button>
|
<button onclick="fullscreenPlayer()">1.Fullscreen</button>
|
<button onclick="nextFrame()">1.Next Frame</button>
<button onclick="snapshot()">2.Snapshot</button>
<button onclick="playrate(0.5)">3.PlayRate 0.5</button>
<button onclick="resize(640, 200)">resize640x200</button>
<hr>
</div>
<pre>
--> 1.Install Player
--> when [onReadyShowDone] happened
--> 2.Play/Pause/Seek/Other operations
--> 3.Release Player
</pre>
<a href="https://github.com/numberwolf/h265web.js">https://github.com/numberwolf/h265web.js</a>
<script>
if((/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent))) {
alert("safari");
}
const h265webURL = "https://github.com/numberwolf/h265web.js";
var playerObj = null;
var loggerObj = document.getElementById("logger");
var loggerCacheObj = document.getElementById("logger-cache");
var loggerPtsObj = document.getElementById("logger-pts");
function clear() {
window.STATICE_MEM_playerCount = -1;
window.STATICE_MEM_playerIndexPtr = 0;
} // end func clear
function releasePlayer() {
if (playerObj !== null) {
playerObj.release();
playerObj = null;
// log
loggerObj.value = h265webURL + "\r\nRelease done!";
document.getElementById("play-button").setAttribute("disabled", "disabled");
}
}
function installPlayer() {
clear();
const textarea_conf = document.getElementById("config-input");
const textarea_conf_value = textarea_conf.value;
const config = JSON.parse(textarea_conf_value);
const play_url = document.getElementById("url-input").value;
console.log(textarea_conf_value);
console.log(config);
console.log(play_url);
/*
*
*
* 1. create player object
*
*
*/
playerObj = window.new265webjs(play_url, config);
/*
*
*
* 2. bind events
*
*
*/
playerObj.onSeekStart = (pts) => {
loggerObj.scrollNewest("\r\nonSeekStart:" + pts);
};
playerObj.onSeekFinish = () => {
loggerObj.scrollNewest("\r\nonSeekFinish");
};
playerObj.onPlayFinish = () => {
loggerObj.scrollNewest("\r\nonPlayFinish");
};
playerObj.onRender = (width, height, imageBufferY, imageBufferB, imageBufferR) => {
loggerObj.scrollNewest("\r\nonRender");
};
playerObj.onOpenFullScreen = () => {
loggerObj.scrollNewest("\r\nonOpenFullScreen");
};
playerObj.onCloseFullScreen = () => {
loggerObj.scrollNewest("\r\nonCloseFullScreen");
};
playerObj.onSeekFinish = () => {
loggerObj.scrollNewest("\r\nonSeekFinish");
};
playerObj.onLoadCache = () => {
loggerObj.scrollNewest("\r\nonLoadCache");
};
playerObj.onLoadCacheFinshed = () => {
loggerObj.scrollNewest("\r\nonLoadCacheFinshed");
};
playerObj.onReadyShowDone = () => {
loggerObj.scrollNewest("\r\nonReadyShowDone:【You can play now】");
document.getElementById("play-button").removeAttribute("disabled");
};
playerObj.onLoadFinish = () => {
loggerObj.scrollNewest("\r\nonLoadFinish");
playerObj.setVoice(1.0);
mediaInfo = playerObj.mediaInfo();
console.log("onLoadFinish mediaInfo===========>", mediaInfo);
/*
meta:
isHEVC: true
durationMs: 144400
fps: 25
sampleRate: 44100
size: {
width: 864,
height: 480
},
audioNone : false
videoType: "vod"
*/
let codecName = "h265";
if (mediaInfo.meta.isHEVC === false) {
loggerObj.scrollNewest("\r\nonLoadFinish is Not HEVC/H.265");
codecName = "h264";
} else {
loggerObj.scrollNewest("\r\nonLoadFinish is HEVC/H.265");
}
loggerObj.scrollNewest("\r\nonLoadFinish media Codec:" + codecName);
loggerObj.scrollNewest("\r\nonLoadFinish media FPS:" + mediaInfo.meta.fps);
loggerObj.scrollNewest("\r\nonLoadFinish media size:" + mediaInfo.meta.size.width + "x" + mediaInfo.meta.size.height);
if (mediaInfo.meta.audioNone) {
loggerObj.scrollNewest("\r\nonLoadFinish media no Audio");
} else {
loggerObj.scrollNewest("\r\nonLoadFinish media sampleRate:" + mediaInfo.meta.sampleRate);
}
if (mediaInfo.videoType == "vod") {
loggerObj.scrollNewest("\r\nonLoadFinish media is VOD");
loggerObj.scrollNewest("\r\nonLoadFinish media dur:" + Math.ceil(mediaInfo.meta.durationMs) / 1000.0);
} else {
loggerObj.scrollNewest("\r\nonLoadFinish media is LIVE");
}
};
playerObj.onCacheProcess = (cPts) => {
loggerCacheObj.scrollNewest("onCacheProcess:" + cPts);
};
playerObj.onPlayTime = (videoPTS) => {
if (mediaInfo.videoType == "vod") {
loggerPtsObj.scrollNewest("onPlayTime:" + videoPTS);
} else {
// LIVE
}
};
/*
*
*
* 3. install player
*
*
*/
playerObj.do();
} // end func installPlayer
function playPausePlayer() {
if (playerObj !== null) {
if (playerObj.isPlaying()) {
loggerObj.scrollNewest("\r\nplayerObj.pause()");
playerObj.pause();
} else {
loggerObj.scrollNewest("\r\nplayerObj.play()");
playerObj.play();
}
}
} // end func playPausePlayer
function seekPlayer() {
loggerObj.scrollNewest("\r\nplayerObj.seek(5)");
if (playerObj !== null) {
playerObj.seek(5);
}
} // end func seekPlayer
function mutePlayer() {
loggerObj.scrollNewest("\r\nplayerObj.setVoice(0)");
if (playerObj !== null) {
playerObj.setVoice(0);
}
} // end func mutePlayer
function unmutePlayer() {
loggerObj.scrollNewest("\r\nplayerObj.setVoice(1.0)");
if (playerObj !== null) {
playerObj.setVoice(1.0);
}
} // end func unmutePlayer
function fullscreenPlayer() {
loggerObj.scrollNewest("\r\nplayerObj.fullScreen()");
if (playerObj !== null) {
playerObj.fullScreen();
}
}
function nextFrame() {
loggerObj.scrollNewest("\r\nplayerObj.playNextFrame()");
if (playerObj !== null) {
playerObj.playNextFrame();
}
}
function snapshot() {
const snapCanvas = document.querySelector("#snapshot-canvas");
if (playerObj !== null) {
playerObj.snapshot(snapCanvas);
loggerObj.scrollNewest("\r\nplayerObj.snapshot");
}
}
function playrate(rate=1.0) {
console.log(playerObj.player.videoTag);
if (playerObj !== null) {
let ret = playerObj.setPlaybackRate(rate);
loggerObj.scrollNewest(
"\r\nplayerObj playrate:"
+ ' ret:' + ret
+ ' tag:' + rate
+ ' res:' + playerObj.getPlaybackRate());
}
}
function resize(w, h) {
if (playerObj !== null) {
let ret = playerObj.resize(w, h);
loggerObj.scrollNewest(
"\r\nplayerObj resize:"
+ ' ret:' + ret
+ ' w:' + w
+ ' h:' + h);
}
}
window.onload = function() {
if (loggerObj === null) {
loggerObj = document.getElementById("logger");
loggerCacheObj = document.getElementById("logger-cache");
loggerPtsObj = document.getElementById("logger-pts");
}
loggerObj.scrollNewest = function(val) {
loggerObj.value += val;
loggerObj.scrollTop = loggerObj.scrollHeight;
};
loggerCacheObj.scrollNewest = function(val) {
loggerCacheObj.value = val;
//loggerCacheObj.scrollTop = loggerCacheObj.scrollHeight;
};
loggerPtsObj.scrollNewest = function(val) {
loggerPtsObj.value = val;
//loggerPtsObj.scrollTop = loggerPtsObj.scrollHeight;
};
}; // end onload
</script>
</body>
</html>