-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
618 lines (596 loc) · 26.8 KB
/
index.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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<!DOCTYPE html>
<!--
**
** VDO.Ninja Trampoline
** Copyright (c) 2021 Dr. Ralf S. Engelschall <[email protected]>
** Licensed under MIT license <https://spdx.org/licenses/MIT.html>
**
-->
<html>
<head>
<title>VDO.Ninja Trampoline</title>
<meta charset="UTF-8"/>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<style type="text/css">
html, body {
margin: 0;
width: 100vw;
height: 100vh;
background-color: transparent;
}
body {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #c0c0c0;
}
.box {
background: linear-gradient(#444444, #000000);
color: #ffffff;
font-family: sans-serif;
font-size: 11pt;
display: flex;
flex-direction: column;
justify-content: flex-start;
padding: 20px 30px 20px 30px;
border-radius: 8px;
box-shadow: 0px 4px 8px #666666;
}
.box .row {
display: flex;
flex-direction: row;
justify-content: flex-start;
margin-bottom: 4px;
}
.box .desc {
width: 600px;
margin-bottom: 12px;
color: #e0e0e0;
text-align: justify;
font-size: 10pt;
}
.box a {
text-decoration: none;
color: #ffffff;
}
.box .title {
color: #ffffff;
font-weight: bold;
margin-right: 8px;
width: 100%;
margin-bottom: 8px;
font-size: 150%;
}
.box .label {
margin-right: 4px;
width: calc(140px - 4px);
color: #e0e0e0;
}
.box .field {
width: 460px;
}
.box input[type='text'] {
background-color: #333333;
color: #ffffff;
border: 1px solid #999999;
font-size: 11pt;
padding: 2px 8px 2px 8px;
width: calc(100% - 16px);
}
.box input[type='text']:hover,
.box input[type='text']:focus {
background-color: #336699;
outline: none;
}
.box select {
background-color: #333333;
color: #ffffff;
border: 1px solid #999999;
font-size: 11pt;
padding: 2px 4px 2px 4px;
width: calc(90% - 8px);
}
.box select:hover,
.box select:focus {
background-color: #336699;
outline: none;
}
.box #effect.disabled,
.box #peer.disabled,
.box #name.disabled {
background-color: #666666;
border: 1px solid #999999;
}
.box .url {
background-color: #666666;
color: #ffffff;
border: 1px solid #999999;
font-size: 11pt;
padding: 2px 4px 2px 4px;
width: calc(100% - 8px);
font-family: monospace;
}
.box input[type='submit'] {
background-color: #cccccc;
font-size: 11pt;
border: 1px solid #cccccc;
color: #000000;
padding: 2px 4px 2px 4px;
width: 100%;
font-weight: bold;
border-radius: 4px;
margin: 0;
margin-bottom: 4px;
}
.box input[type='submit']:hover {
background-color: #336699;
border: 1px solid #336699;
color: #ffffff;
}
.box input[type='submit'].cancel {
background-color: #993333;
border: 1px solid #993333;
color: #ffffff;
}
.box .foot {
text-align: right;
width: 600px;
margin-top: 8px;
font-size: 8pt;
color: #a0a0a0;
}
.box .foot a {
color: #c0c0c0;
}
.box .row.source {
margin-top: 16px;
}
</style>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div class="box">
<!-- headline -->
<div class="row">
<div class="title">VDO.Ninja Trampoline</div>
</div>
<!-- description -->
<div class="row">
<div class="desc">
<a href="https://vdo.ninja">VDO.Ninja</a> (formerly OBS.Ninja) is an awesome peer-to-peer (P2P),
<a href="https://webrtc.org/">WebRTC</a> and browser based solution
for bringing the video/audio streams of presenters into the live event
production software <a href="https://obsproject.com">OBS Studio</a>,
with very low latency and high quality.
This form is just a URL simplification
trampoline, i.e., it takes a few intuitive URL parameters and redirects to the
underlying complex technical URL of <a href="https://vdo.ninja">VDO.Ninja</a>. It allows
you to control <a href="https://vdo.ninja">VDO.Ninja</a> parameters at a central
place while being able to use clean, intuitive and stable URLs for both the
presenters and <a href="https://obsproject.com">OBS Studio</a>.
The underlying <a href="https://vdo.ninja">VDO.Ninja</a>
parameter sets are rather opinionated and hard-coded and are intended for
meeting or broadcast sessions with multiple presenters only. Broadcast sessions are
like meetings, where presenters can hear but not see each other,
to reduce the network bandwidth requirements of presenters.
</div>
</div>
<!-- input parameters -->
<div class="row">
<div class="label">Room Id:</div>
<div class="field">
<input id="room" class="input-room" type="text" value="example"></input>
</div>
</div>
<div class="row">
<div class="label">Room Password:</div>
<div class="field">
<input id="pass" class="input-password" type="text" value="example"></input>
</div>
</div>
<div class="row">
<div class="label">Session Mode:</div>
<div class="field">
<select id="mode" class="select-mode">
<option value="attendee" selected="selected">attendee (person in meeting)</option>
<option value="sender">sender (person in broadcast)</option>
<option value="follower">follower (person in broadcast, no-video)</option>
<option value="injector">injector (person in broadcast, no-video, no-audio)</option>
<option value="receiver">receiver (OBS Studio Browser Source, single sender)</option>
<option value="collector">collector (OBS Studio Browser Source, all senders)</option>
<option value="director">director (person controlling)</option>
</select>
</div>
</div>
<div class="row">
<div class="label">Audio Mode:</div>
<div class="field">
<select id="audio" class="select-audio">
<option value="stereo" selected="selected">stereo (2 channels)</option>
<option value="mono">mono (1 channel)</option>
</select>
</div>
</div>
<div class="row">
<div class="label">Video Mode:</div>
<div class="field">
<select id="video" class="select-video">
<option value="1080p">1080p (Full-HD, 1920x1080px, dynamic/smart)</option>
<option value="720p" selected="selected">720p (HD, 1280x720px, dynamic/smart)</option>
<option value="576p">576p (SD, 1024x576px, static/fixed)</option>
<option value="480p">480p (854x480px, static/fixed)</option>
<option value="360p">360p (640x360px, dynamic/smart)</option>
<option value="240p">240p (426x240px, static/fixed)</option>
<option value="144p">144p (256x144px, static/fixed)</option>
</select>
</div>
</div>
<div class="row">
<div class="label">Video Framerate:</div>
<div class="field">
<select id="fps" class="select-fps">
<option value="10">10.00 fps (1/3 Standard)</option>
<option value="15">15.00 fps (1/2 Standard)</option>
<option value="20">20.00 fps (2/3 Standard)</option>
<option value="24">24.00 fps (Cinema)</option>
<option value="25">25.00 fps (PAL)</option>
<option value="29.97">29.97 fps (NTSC)</option>
<option value="30" selected="selected">30.00 fps (Standard)</option>
<option value="40">40.00 fps (4/3 Standard)</option>
<option value="48">48.00 fps (2x Cinema)</option>
<option value="50">50.00 fps (2x PAL)</option>
<option value="59.94">59.94 fps (2x NTSC)</option>
<option value="60">60.00 fps (2x Standard)</option>
</select>
</div>
</div>
<div class="row">
<div class="label">Video Effect:</div>
<div class="field">
<select id="effect" class="select-effect">
<option value="none" selected="selected">none</option>
<option value="mirror">horizontal mirror</option>
<option value="bokehblur">bokeh-blur (AI, CPU-intensive)</option>
<option value="greenscreen">green-screen (AI, CPU-intensive)</option>
</select>
</div>
</div>
<div class="row">
<div class="label">Peer Id:</div>
<div class="field">
<input id="peer" class="input-peer" type="text" value="P01"></input>
</div>
</div>
<div class="row">
<div class="label">Peer Name:</div>
<div class="field">
<input id="name" class="input-name" type="text" value="Mr. Example"></input>
</div>
</div>
<!-- source URL -->
<div class="row source">
<div class="label">Source URL:<br/>(your entry point)</div>
<div class="field">
<textarea id="url-trampoline" class="url" rows="3" disabled="disabled"></textarea>
</div>
</div>
<!-- copy button -->
<div class="row">
<div class="label"></div>
<div class="field">
<input id="copy" type="submit" value="COPY"></input>
</div>
</div>
<!-- target URL -->
<div class="row">
<div class="label">Target URL:<br/>(your redirection)</div>
<div class="field">
<textarea id="url-expanded" class="url" rows="6" disabled="disabled"></textarea>
</div>
</div>
<!-- open button -->
<div class="row">
<div class="label"></div>
<div class="field">
<input id="open" type="submit" value="OPEN"></input>
</div>
</div>
<!-- footer -->
<div class="row">
<div class="foot">
<a href="https://github.com/rse/vdo-ninja-trampoline">VDO.Ninja Trampoline</a> 1.0.1 (2021-06-01)<br/>
Copyright © 2021 <a href="mailto:[email protected]">Dr. Ralf S. Engelschall</a><br/>
Licensed under <a href="https://spdx.org/licenses/MIT.html">MIT license</a>
</div>
</div>
</div>
</body>
<script type="text/javascript">
const isChrome = !!window.chrome
const isOBS = !!window.obsstudio
const isIOS = !!window.navigator.userAgent.match(/(?:iPad|iPhone)/i)
if (!(isChrome || isOBS || isIOS))
alert("ALERT: Sorry, Google Chrome or a Chromium-based browser is strongly recommended for VDO.Ninja. " +
"Firefox, Safari or other browsers are not very well supported. " +
"Please start over with Google Chrome!")
$(document).ready(() => {
/* generate VDO.Ninja URL */
const makeURL = (room, pass, mode, audio, video, fps, effect, peer, name) => {
/* determine audio quality */
let st = 1
let ab = 256
switch (audio) {
case "stereo": st = 1; ab = 256; break
case "mono": st = 0; ab = 96; break
}
/* determine video resolution */
let w = -1
let h = -1
let q = -1
let vb = 2500
switch (video) {
case "1080p": q = 0; vb = 2500; break
case "720p": q = 1; vb = 1000; break
case "576p": vb = 750; w = 1024; h = 576; break
case "480p": vb = 500; w = 854; h = 480; break
case "360p": q = 2; vb = 250; break
case "240p": vb = 125; w = 426; h = 240; break
case "144p": vb = 75; w = 256; h = 144; break
}
/* determine video effect */
let ve = ""
switch (effect) {
case "mirror": ve = "&effects=2"; break
case "bokehblur": ve = "&effects=3"; break
case "greenscreen": ve = "&effects=4"; break
}
/* generate URL... */
let url = "https://vdo.ninja/?"
const label = encodeURIComponent(name.replace(/_/g, " "))
const pw = (pass === "?" ? "&password" : (pass !== "" ? `&password=${pass}` : ""))
let order = 0
if (mode === "attendee" || mode === "sender") {
let m
if ((m = peer.match(/(\d+)/)) !== null)
order = Math.max(0, 100 - parseInt(m[1]))
}
if (mode === "attendee") {
/* ...for attendee (meeting) */
url += `room=${room}` + pw +
`&push=${peer}&ssid=${peer}S&label=${label}&order=${order}` +
(q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` + ve +
`&stereo=${st}&audiobitrate=${ab}&aec=1&ag=0&dn=1&lowcut=80` +
"&noheader" +
"&hand&beep&webcam" +
"&ssb"
}
else if (mode === "sender") {
/* ...for sender (broadcast) */
url += `room=${room}` + pw +
`&push=${peer}&ssid=${peer}S&label=${label}&order=${order}` +
(q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` + ve +
`&stereo=${st}&audiobitrate=${ab}&aec=1&ag=0&dn=1&lowcut=80` +
"&broadcast&preview" +
"&hand&beep&webcam" +
"&ssb"
}
else if (mode === "follower") {
/* ...for follower (broadcast, no-video) */
url += `room=${room}` + pw +
`&push=${peer}&ssid=${peer}S&label=${label}` +
(q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` +
`&stereo=${st}&audiobitrate=${ab}&aec=1&ag=0&dn=1&lowcut=80` +
"&videodevice=0" +
"&mute" +
"&broadcast&nopreview" +
"&hand&beep&webcam" +
"&obsoff"
}
else if (mode === "injector") {
/* ...for injector (broadcast, no-video, no-audio) */
url += `room=${room}` + pw +
`&push=${peer}&ssid=${peer}S&label=${label}` +
(q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` +
`&stereo=${st}&audiobitrate=${ab}&aec=1&ag=0&dn=1&lowcut=80` +
"&novideo&videodevice=0" +
"&noaudio&audiodevice=0" +
"&nosettings&autostart" +
"&broadcast&nopreview" +
"&hand&beep&webcam" +
"&obsoff"
}
else if (mode === "receiver") {
/* ...for receiver (OBS Studio, Browser Source) */
url += `room=${room}` + pw
url += (peer === "AS" ? "&scene=1" : `&view=${peer}&scene`)
if (name !== "")
url += `&label=${label}`
url += (q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` +
`&stereo=${st}&audiobitrate=${ab}` +
`&bitrate=${vb + ab + 200}` +
"&transparent&cleanoutput&nocursor"
}
else if (mode === "collector") {
/* ...for collector (OBS Studio all-on-one collector) */
url += `room=${room}` + pw
url += "&scene"
if (name !== "")
url += `&label=${label}`
url += (q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` +
`&stereo=${st}&audiobitrate=${ab}` +
`&bitrate=${vb + ab + 200}` +
"&transparent&cleanoutput&nocursor"
}
else if (mode === "director") {
/* ...for director (event operator) */
url += `director=${room}` + pw +
`&push=${peer}&ssid=${peer}S&label=${label}` +
(q !== -1 ? `&quality=${q}` : `&width=${w}&height=${h}`) +
`&framerate=${fps}&videobitrate=${vb}&codec=h264` +
`&stereo=${st}&audiobitrate=${ab}&aec=1&ag=0&dn=1&lowcut=80` +
"&noheader&cleandirector"
}
return url
}
/* update URLs on form changes */
const updateURLs = () => {
/* fetch information of form */
const room = $("#room").val()
const pass = $("#pass").val()
const mode = $("#mode option:selected").val()
const audio = $("#audio option:selected").val()
const video = $("#video option:selected").val()
const fps = $("#fps option:selected").val()
const effect = $("#effect option:selected").val()
const peer = $("#peer").val()
const name = $("#name").val().replace(/\s+/g, "_")
/* generate URLs */
let urlTrampoline = window.location.href.replace(/#.*$/, "") +
`#/${room}/${pass}/${mode}/${audio}/${video}/${fps}/${effect}`
if (peer !== "")
urlTrampoline += `/${peer}`
if (name !== "")
urlTrampoline += `/${name}`
const urlExpanded = makeURL(room, pass, mode, audio, video, fps, effect, peer, name)
/* update information in form */
$("#url-trampoline").val(urlTrampoline)
$("#url-expanded").val(urlExpanded)
}
$("#room, #pass, #peer, #name").bind("keyup", () => {
updateURLs()
})
$("#mode, #audio, #video, #fps, #effect").bind("change", () => {
updateURLs()
})
$("#mode").bind("change", () => {
const mode = $("#mode option:selected").val()
if (mode === "receiver") {
$("#name").attr("disabled", "disabled")
$("#name").addClass("disabled")
$("#name").val("")
}
else if (mode === "collector") {
$("#peer").attr("disabled", "disabled")
$("#peer").addClass("disabled")
$("#peer").val("")
$("#name").attr("disabled", "disabled")
$("#name").addClass("disabled")
$("#name").val("")
}
else {
$("#peer").removeAttr("disabled")
$("#peer").removeClass("disabled")
$("#peer").val("P01")
$("#name").removeAttr("disabled")
$("#name").removeClass("disabled")
$("#name").val("Mr. Example")
}
if (mode === "attendee" || mode === "sender") {
$("#effect").removeAttr("disabled")
$("#effect").removeClass("disabled")
}
else {
$("#effect").attr("disabled", "disabled")
$("#effect").addClass("disabled")
$("#effect").val("none")
}
updateURLs()
})
updateURLs()
/* final open */
const open = () => {
const url = $("#url-expanded").val()
window.location.href = url
}
/* countdown to open */
let timer = null
let count = 2
const startopen = () => {
if (timer !== null)
clearTimeout(timer)
timer = setInterval(() => {
if (count > 0) {
$("#open").val(`CANCEL OPEN (redirecting in ${count} seconds)`)
if (!$("#open").hasClass("cancel"))
$("#open").addClass("cancel")
count--
}
else {
clearTimeout(timer)
$("#open").val("OPEN").removeClass("cancel")
open()
}
}, 1000)
}
/* initial (page load) or interactive hash-change */
const takehash = () => {
/* take and parse hash */
const hash = window.location.hash
const m = hash.match(/^#\/([^/]+)\/([^/]*)\/([^/]+)(?:\/([^/]+)(?:\/([^/]+)(?:\/([^/]+)(?:\/([^/]+)(?:\/([^/]+)(?:\/([^/]+))?)?)?)?)?)?$/)
if (m === null)
return
let [ , room, pass, mode, audio, video, fps, effect, peer, name ] = m
if (audio === undefined) audio = "mono"
if (video === undefined) video = "1080p"
if (fps === undefined) fps = "30"
if (effect === undefined) effect = "none"
if (peer === undefined) peer = ""
if (name === undefined) name = ""
/* canonicalize values */
if (typeof name === "string")
name = name.replace(/_/g, " ")
/* fill form inputs */
$("#room").val(room)
$("#pass").val(pass)
$(`#mode option[value='${mode}']`).attr("selected", "selected").change()
$(`#audio option[value='${audio}']`).attr("selected", "selected").change()
$(`#video option[value='${video}']`).attr("selected", "selected").change()
$(`#fps option[value='${fps}']`).attr("selected", "selected").change()
$(`#effect option[value='${effect}']`).attr("selected", "selected").change()
$("#peer").val(peer)
$("#name").val(name)
/* update form outputs */
updateURLs()
/* start a countdown to open */
startopen()
}
$(window).bind("hashchange", (ev) => {
takehash()
})
takehash()
/* interactive copy */
$("#copy").click((ev) => {
const textarea = $("#url-trampoline").get(0)
var selection = document.getSelection()
var range = document.createRange()
range.selectNode(textarea)
selection.removeAllRanges()
selection.addRange(range)
document.execCommand("copy")
selection.removeAllRanges()
})
/* interactive open */
$("#open").click((ev) => {
if (timer !== null && count >= 0) {
clearTimeout(timer)
timer = null
$("#open").val("OPEN").removeClass("cancel")
}
else
open()
ev.preventDefault()
})
})
</script>
</html>