forked from steveseguin/vdo.ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodecs.html
More file actions
1769 lines (1510 loc) · 58.9 KB
/
codecs.html
File metadata and controls
1769 lines (1510 loc) · 58.9 KB
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- codecs.html !-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>VDO.Ninja Codec Support Detector</title>
<meta id="metaTitle" name="title" content="VDO.Ninja Codec Support Detector">
<meta name="description" content="Check browser codec support for VDO.Ninja. Detect hardware acceleration for video encoding and decoding.">
<meta name="author" content="Steve Seguin">
<meta name="copyright" content="© 2024 Steve Seguin">
<meta name="license" content="https://github.com/steveseguin/vdo.ninja/LICENSE.md">
<meta name="sourcecode" content="https://github.com/steveseguin/vdo.ninja">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://vdo.ninja/codec">
<link rel="author" href="/about">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#0f131d">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<link id="favicon1" rel="icon" type="image/png" sizes="32x32" href="./media/favicon-32x32.png">
<link id="favicon2" rel="icon" type="image/png" sizes="16x16" href="./media/favicon-16x16.png">
<link id="favicon3" rel="icon" href="./media/favicon.ico">
<!-- X (Twitter) Card Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@SteveSeguin">
<meta name="twitter:title" content="VDO.Ninja Codec Support Detector">
<meta name="twitter:description" content="Check browser codec support for VDO.Ninja. Detect hardware acceleration for video encoding and decoding.">
<meta name="twitter:image" content="https://vdo.ninja/media/vdoNinja_logo_full.png">
<!-- Open Graph Tags -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://vdo.ninja/codec">
<meta property="og:title" content="VDO.Ninja Codec Support Detector">
<meta property="og:description" content="Check browser codec support for VDO.Ninja. Detect hardware acceleration for video encoding and decoding.">
<meta property="og:image" content="https://vdo.ninja/media/vdoNinja_logo_full.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:site_name" content="VDO.Ninja">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
line-height: 1.6;
color: #e0e0e0;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #121212;
}
h1, h2, h3 {
color: #4296f5;
}
a {
color: #4296f5;
}
.container {
background-color: #1e1e1e;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
padding: 20px;
margin-bottom: 20px;
}
.codec-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 15px;
margin-top: 20px;
}
.codec-item {
background-color: #2a2a2a;
border-radius: 6px;
padding: 15px;
border-left: 4px solid #4296f5;
position: relative;
}
.badge {
display: inline-block;
padding: 3px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: bold;
margin-right: 5px;
margin-bottom: 5px;
}
.badge-hw {
background-color: #34a853;
color: white;
}
.badge-sw {
background-color: #fbbc04;
color: white;
}
.badge-recorder {
background-color: #4296f5;
color: white;
}
.badge-webcodec {
background-color: #ea4335;
color: white;
}
.badge-webrtc {
background-color: #8f44eb;
color: white;
}
.badge-mediacapabilities {
background-color: #ff6d01;
color: white;
}
.badge-encoder {
background-color: #01c0ff;
color: white;
}
.badge-decoder {
background-color: #ff01c0;
color: white;
}
.codec-name {
font-weight: bold;
margin-bottom: 8px;
}
.details {
font-size: 14px;
color: #aaa;
margin-top: 10px;
}
.status-bar {
height: 4px;
width: 100%;
background-color: #333;
position: relative;
margin-bottom: 20px;
border-radius: 2px;
overflow: hidden;
}
.status-progress {
position: absolute;
height: 100%;
background-color: #4296f5;
transition: width 0.3s;
}
.tabs {
display: flex;
margin-bottom: 15px;
border-bottom: 1px solid #444;
}
.tab {
padding: 10px 20px;
cursor: pointer;
border-bottom: 3px solid transparent;
color: #aaa;
}
.tab.active {
border-bottom: 3px solid #4296f5;
font-weight: bold;
color: #e0e0e0;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
button {
background-color: #4296f5;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-weight: bold;
}
button:hover {
background-color: #2979e2;
}
button:disabled {
background-color: #555;
cursor: not-allowed;
}
#error-message {
color: #ff5252;
font-weight: bold;
margin-top: 10px;
}
.toggle-container {
display: flex;
margin: 15px 0;
align-items: center;
}
.toggle-label {
margin-right: 10px;
}
.toggle-switch {
position: relative;
display: inline-block;
width: 60px;
height: 28px;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #333;
transition: .4s;
border-radius: 34px;
}
.toggle-slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 4px;
bottom: 4px;
background-color: #fff;
transition: .4s;
border-radius: 50%;
}
input:checked + .toggle-slider {
background-color: #4296f5;
}
input:checked + .toggle-slider:before {
transform: translateX(32px);
}
.toggle-text {
margin-left: 10px;
}
pre {
background: #2a2a2a;
padding: 15px;
overflow: auto;
max-height: 400px;
color: #e0e0e0;
border-radius: 4px;
}
.codec-guide-container {
display: flex;
flex-direction: column;
gap: 30px;
}
.codec-section {
background-color: #2a2a2a;
border-radius: 8px;
padding: 20px;
margin-bottom: 15px;
}
.codec-section h4 {
color: #4296f5;
margin-top: 0;
margin-bottom: 10px;
border-bottom: 1px solid #444;
padding-bottom: 8px;
}
.usage-block, .tips-block, .note-block, .feature-block {
background-color: #333;
border-radius: 6px;
padding: 15px;
margin-bottom: 15px;
}
.usage-header, .tip-header, .note-header, .feature-header {
font-weight: bold;
color: #4296f5;
margin-bottom: 10px;
}
.usage-example {
font-family: monospace;
background-color: #222;
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 8px;
white-space: nowrap;
overflow-x: auto;
}
.options-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
margin-bottom: 15px;
}
.option-row {
display: flex;
border-bottom: 1px solid #444;
}
.option-row:last-child {
border-bottom: none;
}
.header-row {
background-color: #333;
font-weight: bold;
}
.option-cell {
padding: 10px;
flex: 1;
}
.option-cell:first-child {
flex: 0 0 120px;
}
.option-cell code {
background-color: #222;
padding: 2px 5px;
border-radius: 3px;
font-family: monospace;
}
.tips-list, .note-list, .feature-list {
margin: 0;
padding-left: 20px;
}
.tips-list li, .note-list li, .feature-list li {
margin-bottom: 8px;
}
@media (max-width: 768px) {
.option-row {
flex-direction: column;
}
.option-cell {
padding: 8px;
}
.option-cell:first-child {
flex: 1;
background-color: #333;
font-weight: bold;
}
.header-row {
display: none;
}
}
</style>
</head>
<body>
<h1>Video Codec Support Detector</h1>
<div class="container">
<h2>Codec Detection</h2>
<p>This tool detects video and audio codecs supported by your browser and identifies hardware acceleration capabilities for both encoding and decoding.</p>
<div class="toggle-container">
<span class="toggle-label">Detection Mode:</span>
<label class="toggle-switch">
<input type="checkbox" id="toggle-mode" checked>
<span class="toggle-slider"></span>
</label>
<span class="toggle-text" id="mode-text">Testing Both Encode/Decode</span>
</div>
<div class="status-bar">
<div id="status-progress" class="status-progress" style="width: 0%"></div>
</div>
<button id="start-detection">Start Comprehensive Detection</button>
<div id="error-message"></div>
</div>
<div class="container">
<div class="tabs">
<div class="tab active" data-tab="video-codecs">Video Codecs</div>
<div class="tab" data-tab="audio-codecs">Audio Codecs</div>
<div class="tab" data-tab="raw-data">Raw Data</div>
<div class="tab" data-tab="codec-usage">Codec Usage Guide</div>
</div>
<div id="video-codecs" class="tab-content active">
<h3>Video Codec Support</h3>
<div id="video-codec-list" class="codec-list">
<p>Click "Start Comprehensive Detection" to begin...</p>
</div>
</div>
<div id="audio-codecs" class="tab-content">
<h3>Audio Codec Support</h3>
<div id="audio-codec-list" class="codec-list">
<p>Click "Start Comprehensive Detection" to begin...</p>
</div>
</div>
<div id="raw-data" class="tab-content">
<h3>Raw Detection Data</h3>
<pre id="output" style="background: #2a2a2a; padding: 15px; overflow: auto; max-height: 400px;"></pre>
</div>
</div>
<div id="codec-usage" class="tab-content">
<h3>How to Use Codecs in VDO.Ninja</h3>
<div class="codec-guide-container">
<div class="codec-section">
<h4>Video Codec Selection (&codec)</h4>
<p>Control which codec is used to encode and transmit video.</p>
<div class="usage-block">
<div class="usage-header">Basic Usage</div>
<div class="usage-example">https://vdo.ninja/?view=abc123&codec=h264</div>
<div class="usage-example">https://vdo.ninja/?room=xxx7654&scene&bitrate=2000&codec=vp9</div>
</div>
<div class="options-table">
<div class="option-row header-row">
<div class="option-cell">Option</div>
<div class="option-cell">Description</div>
<div class="option-cell">Use Case</div>
</div>
<div class="option-row">
<div class="option-cell"><code>h264</code></div>
<div class="option-cell">Request H.264 codec</div>
<div class="option-cell">Better battery life on mobile devices, hardware acceleration on many devices</div>
</div>
<div class="option-row">
<div class="option-cell"><code>vp8</code></div>
<div class="option-cell">Request VP8 codec</div>
<div class="option-cell">Default codec, works on most devices</div>
</div>
<div class="option-row">
<div class="option-cell"><code>vp9</code></div>
<div class="option-cell">Request VP9 codec</div>
<div class="option-cell">Better compression, cleaner image for screen sharing</div>
</div>
<div class="option-row">
<div class="option-cell"><code>av1</code></div>
<div class="option-cell">Request AV1 codec</div>
<div class="option-cell">Most advanced compression, requires Chrome v90+</div>
</div>
<div class="option-row">
<div class="option-cell"><code>h265</code></div>
<div class="option-cell">Request H.265/HEVC codec</div>
<div class="option-cell">High efficiency codec, <a href="https://vdo.ninja/h265" target="_blank">limited browser support</a></div>
</div>
<div class="option-row">
<div class="option-cell"><code>webp</code></div>
<div class="option-cell">Request WebP codec</div>
<div class="option-cell">Alternative image-based codec</div>
</div>
<div class="option-row">
<div class="option-cell"><code>hardware</code></div>
<div class="option-cell">Android-specific option for hardware encoding</div>
<div class="option-cell">Android devices struggling with video quality</div>
</div>
<div class="option-row">
<div class="option-cell"><code>av1,h264</code></div>
<div class="option-cell">Comma-separated fallback options</div>
<div class="option-cell">Try AV1 first, fall back to H264 if not supported</div>
</div>
</div>
<div class="tips-block">
<div class="tip-header">Selection Tips</div>
<ul class="tips-list">
<li><strong>H.264:</strong> Hardware accelerated on many devices, good for mobile battery life</li>
<li><strong>VP8:</strong> Default choice, software-encoded but compatible with most devices</li>
<li><strong>VP9:</strong> Better quality at same bitrate vs VP8, but more CPU intensive</li>
<li><strong>AV1:</strong> Best compression ratio but highest CPU usage, limited device support</li>
<li><strong>H.265:</strong> Limited browser support, needs <a href="https://vdo.ninja/h265" target="_blank">command-line flags in Chrome</a></li>
</ul>
</div>
<div class="note-block">
<div class="note-header">Important Notes</div>
<ul class="note-list">
<li>The <code>&codec</code> parameter is added to the viewer-side (use with <code>&view</code> or <code>&scene</code>)</li>
<li>Hardware encoding capabilities vary by device, OS, and browser.</li>
<li>H.264 hardware encoding might use less battery but sometimes has compatibility issues</li>
<li>AV1 and VP9 tends to look better for screen sharing but uses more CPU</li>
<li>AV1 tends to offer more accurate colours; useful for chroma green screening</li>
<li>Use the detection tool above to see which codecs have hardware acceleration on your device</li>
</ul>
</div>
</div>
<div class="codec-section">
<h4>Recording Options (&record)</h4>
<p>Configure how video and audio are recorded to disk.</p>
<div class="usage-block">
<div class="usage-header">Basic Usage</div>
<div class="usage-example">https://vdo.ninja/?push=abc123&record=2000</div>
<div class="usage-example">https://vdo.ninja/?push=xxx7654&record=0</div>
</div>
<div class="options-table">
<div class="option-row header-row">
<div class="option-cell">Option</div>
<div class="option-cell">Description</div>
<div class="option-cell">Use Case</div>
</div>
<div class="option-row">
<div class="option-cell"><code>0</code></div>
<div class="option-cell">No video, audio recorded as 32bit PCM lossless</div>
<div class="option-cell">High-quality audio only recording</div>
</div>
<div class="option-row">
<div class="option-cell"><code>-120</code> (negative)</div>
<div class="option-cell">No video, audio at specified kbps (OPUS)</div>
<div class="option-cell">Audio-only recording with specific bitrate</div>
</div>
<div class="option-row">
<div class="option-cell"><code>2000</code> (positive)</div>
<div class="option-cell">Video bitrate in kbps</div>
<div class="option-cell">Video recording with specific quality setting</div>
</div>
<div class="option-row">
<div class="option-cell"><code>false</code> or <code>off</code></div>
<div class="option-cell">Disable recording feature</div>
<div class="option-cell">Prevents user from recording</div>
</div>
</div>
<div class="note-block">
<div class="note-header">Recording Notes</div>
<ul class="note-list">
<li>Recorded file format is WebM with VP8/H264 video and OPUS/PCM audio</li>
<li>Default bitrate is approximately 4000 kbps if not specified</li>
<li>The director of a room will be notified when a user is recording</li>
<li>The director can trigger recording remotely</li>
<li>Video/audio is saved in real-time to the local download folder</li>
<li>Recording should be stopped manually before closing the browser</li>
</ul>
</div>
</div>
<div class="codec-section">
<h4>Recording Codec Selection (&recordcodec)</h4>
<p>Set the specific codec used when recording to disk.</p>
<div class="usage-block">
<div class="usage-header">Basic Usage</div>
<div class="usage-example">https://vdo.ninja/?push=abc123&record=2000&recordcodec=h264</div>
</div>
<div class="options-table">
<div class="option-row header-row">
<div class="option-cell">Option</div>
<div class="option-cell">Description</div>
</div>
<div class="option-row">
<div class="option-cell"><code>h264</code></div>
<div class="option-cell">Record using H.264 codec</div>
</div>
<div class="option-row">
<div class="option-cell"><code>vp8</code></div>
<div class="option-cell">Record using VP8 codec (default fallback)</div>
</div>
<div class="option-row">
<div class="option-cell"><code>vp9</code></div>
<div class="option-cell">Record using VP9 codec</div>
</div>
<div class="option-row">
<div class="option-cell"><code>av1</code></div>
<div class="option-cell">Record using AV1 codec</div>
</div>
</div>
<div class="note-block">
<div class="note-header">Important Notes</div>
<ul class="note-list">
<li>The container format is always WebM regardless of codec, unless using Safari, and maybe then its MP4</li>
<li>If a codec is not supported, it will fall back to VP8</li>
<li>Especially useful for Chrome on Android where VP8 performance can be poor</li>
<li>Remember to add <code>&record</code> to enable the recording function</li>
<li>Use <code>&rc</code> as a shorter alias for <code>&recordcodec</code></li>
</ul>
</div>
</div>
<div class="codec-section">
<h4>Advanced WebRTC Features</h4>
<p>WebRTC supports additional features like SVC (Scalable Video Coding) and WHiP.</p>
<div class="feature-block">
<div class="feature-header">SVC (Scalable Video Coding)</div>
<p>SVC allows a single bitstream to have multiple resolutions, frame rates, or quality layers.</p>
<ul class="feature-list">
<li>Improves streaming adaptability for viewers with different connection qualities</li>
<li>Support varies by browser and codec</li>
<li>Common modes include L1T1 (single layer), L2T1 (2 spatial layers), S2T1 (2 temporal layers)</li>
<li>The detection tool above shows supported SVC modes for your browser</li>
</ul>
</div>
<div class="feature-block">
<div class="feature-header">WHiP (WebRTC HTTP ingest Protocol)</div>
<p>WHiP is a standardized protocol for sending WebRTC streams to a server.</p>
<ul class="feature-list">
<li>Enables WebRTC streaming to CDNs and streaming platforms</li>
<li>Simpler to implement than custom signaling servers</li>
<li>Useful for broadcast scenarios with many viewers</li>
<li>Check your streaming platform documentation for WHiP support details</li>
</ul>
</div>
<div class="note-block">
<div class="note-header">H.265/HEVC Support</div>
<p>H.265 (HEVC) offers excellent compression efficiency but has limited browser support. <a href="https://vdo.ninja/h265" target="_blank">Visit our H.265 guide</a> for detailed instructions on:</p>
<ul class="note-list">
<li>Enabling H.265 in Chrome using command-line flags</li>
<li>Browser compatibility information</li>
<li>Fallback strategies using comma-separated codec preferences</li>
<li>Testing your browser's H.265 support</li>
</ul>
</div>
</div>
</div>
</div>
<script>
// Main data object to store all detection results
const codecData = {
video: {}, // Will store video codec info
audio: {}, // Will store audio codec info
webrtc: {}, // Will store WebRTC related info
webcodec: {}, // Will store WebCodec related info
mediaCapabilities: {} // Will store MediaCapabilities info
};
// Basic DOM manipulation helpers
const dom = {
get: id => document.getElementById(id),
create: tag => document.createElement(tag),
append: (parent, child) => parent.appendChild(child)
};
// Detection mode
let detectionMode = {
encode: true,
decode: true
};
// Toggle switch for detection mode
dom.get('toggle-mode').addEventListener('change', function() {
if (this.checked) {
detectionMode = { encode: true, decode: true };
dom.get('mode-text').textContent = 'Testing Both Encode/Decode';
} else {
detectionMode = { encode: false, decode: true };
dom.get('mode-text').textContent = 'Testing Decode Only';
}
});
// Tab functionality
document.querySelectorAll('.tab').forEach(tab => {
tab.addEventListener('click', () => {
// Remove active class from all tabs and contents
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
// Add active class to clicked tab and corresponding content
tab.classList.add('active');
dom.get(tab.dataset.tab).classList.add('active');
});
});
// Add this to the codecs.html file, inside the script tag, near the top
// Check for results parameter
function checkForResultsParam() {
const urlParams = new URLSearchParams(window.location.search);
const resultsId = urlParams.get('results');
if (resultsId) {
loadResultsData(resultsId);
// Update the page header
const pageHeader = document.querySelector('h1');
if (pageHeader) {
pageHeader.textContent = 'Loading Remote User Codec Support...';
}
// Disable the start button
const startButton = dom.get('start-detection');
if (startButton) {
startButton.disabled = true;
startButton.textContent = 'Loading Remote Results...';
}
}
}
// Load results data from the server
async function loadResultsData(resultsId) {
try {
// Show progress indicator
setProgress(30);
// Fetch the results data
const response = await fetch(`https://record.vdo.workers.dev/?name=${resultsId}`);
if (!response.ok) {
throw new Error(`Failed to load results (${response.status})`);
}
const results = await response.json();
setProgress(60);
// Process the results
processResultsData(results);
// Update the UI with the loaded data
updateUI();
setProgress(100);
// Update the page header
const pageHeader = document.querySelector('h1');
if (pageHeader) {
pageHeader.textContent = 'Remote User Codec Support';
}
// Update the button text
const startButton = dom.get('start-detection');
if (startButton) {
startButton.textContent = 'Run Local Detection Instead';
startButton.disabled = false;
}
// Add a "back to results" link
const container = document.querySelector('.container');
if (container) {
const backLink = dom.create('div');
backLink.className = 'back-link';
backLink.innerHTML = `<a href="./results?id=${resultsId}">← Back to Test Results</a>`;
container.insertBefore(backLink, container.firstChild);
// Add notification that we're viewing remote data
const remoteNotice = dom.create('div');
remoteNotice.className = 'remote-notice';
remoteNotice.textContent = 'You are viewing codec information from a remote user\'s test results';
container.insertBefore(remoteNotice, container.firstChild);
// Add styles
const style = dom.create('style');
style.textContent = `
.back-link {
margin-bottom: 15px;
}
.back-link a {
color: #4296f5;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.back-link a:hover {
text-decoration: underline;
}
.remote-notice {
background-color: #2a2a2a;
border-left: 4px solid #4296f5;
padding: 10px 15px;
margin-bottom: 15px;
font-weight: bold;
}
`;
document.head.appendChild(style);
}
} catch (error) {
console.error('Error loading results:', error);
showError(`Failed to load results: ${error.message}`);
// Re-enable the start button on error
const startButton = dom.get('start-detection');
if (startButton) {
startButton.disabled = false;
startButton.textContent = 'Start Comprehensive Detection';
}
}
}
// Process the loaded results data
function processResultsData(results) {
// Clear existing codec data
codecData.video = {};
codecData.audio = {};
// Look for codec information in the results
for (const item of results) {
// Look for detectedCodecs data (if it exists in the logged data)
if (item.detectedCodecs) {
// Copy the codec information
Object.assign(codecData.video, item.detectedCodecs.video || {});
Object.assign(codecData.audio, item.detectedCodecs.audio || {});
// Log info about the remote browser
if (item.detectedCodecs.browserInfo) {
addLog(`Remote Browser: ${item.detectedCodecs.browserInfo.userAgent || "Unknown"}`);
}
}
// Look for codecs data - the format used in the test data
if (item.codecs) {
// Process video codecs
if (item.codecs.video) {
Object.keys(item.codecs.video).forEach(codec => {
codecData.video[codec] = codecData.video[codec] || {};
codecData.video[codec].webrtc = true;
codecData.video[codec].canDecode = true;
// Add a badge or icon for these values in the UI
if (codec === 'h264' || codec === 'vp9') {
codecData.video[codec].details = 'Common codec for streaming';
}
});
addLog(`Remote Video Codecs: ${Object.keys(item.codecs.video).join(', ')}`);
}
// Process audio codecs
if (item.codecs.audio) {
Object.keys(item.codecs.audio).forEach(codec => {
codecData.audio[codec] = codecData.audio[codec] || {};
codecData.audio[codec].webrtc = true;
codecData.audio[codec].canDecode = true;
});
addLog(`Remote Audio Codecs: ${Object.keys(item.codecs.audio).join(', ')}`);
}
}
// Look for browser/platform info
if (item.info) {
if (item.info.Browser) {
addLog(`Browser: ${item.info.Browser}`);
}
if (item.info.platform) {
addLog(`Platform: ${item.info.platform}`);
}
if (item.info.gpGPU) {
addLog(`GPU: ${item.info.gpGPU}`);
// Set additional details for hardware acceleration based on GPU
if (codecData.video.h264) {
codecData.video.h264.details = `GPU: ${item.info.gpGPU}`;
}
}
if (item.info.CPU) {
addLog(`CPU: ${item.info.CPU}`);
}
}
// Look for encoder used
if (item.encoder) {
const encoderName = item.encoder.toLowerCase().replace('libvpx', 'vp8');
addLog(`Encoder used in test: ${encoderName}`);
// Mark this codec as used in the test
if (codecData.video[encoderName]) {
codecData.video[encoderName].usedInTest = true;
codecData.video[encoderName].details = `Used during the test`;
}
}
}
}
// Call this function when the page loads
document.addEventListener('DOMContentLoaded', checkForResultsParam);
// Set progress bar
function setProgress(percent) {
dom.get('status-progress').style.width = `${percent}%`;
}
// Show error message
function showError(message) {
dom.get('error-message').textContent = message;
}
// Add log to raw data tab
function addLog(message, isError = false) {
const output = dom.get('output');
const logEntry = document.createElement('div');
logEntry.textContent = message;
if (isError) logEntry.style.color = '#ff5252';
output.appendChild(logEntry);
output.scrollTop = output.scrollHeight;
}
// Create a codec item element with more detailed information
function createCodecItem(codec, info) {
const item = dom.create('div');
item.className = 'codec-item';
const codecName = dom.create('div');
codecName.className = 'codec-name';
codecName.textContent = codec;
const badgesContainer = dom.create('div');
// Add API badges
if (info.mediaRecorder) {
const badge = dom.create('span');
badge.className = 'badge badge-recorder';
badge.textContent = 'MediaRecorder';
badgesContainer.appendChild(badge);
}
if (info.webcodec) {
const badge = dom.create('span');
badge.className = 'badge badge-webcodec';
badge.textContent = 'WebCodec';
badgesContainer.appendChild(badge);
}
if (info.webrtc) {
const badge = dom.create('span');
badge.className = 'badge badge-webrtc';
badge.textContent = 'WebRTC';
badgesContainer.appendChild(badge);
}
if (info.mediaCapabilities) {
const badge = dom.create('span');
badge.className = 'badge badge-mediacapabilities';
badge.textContent = 'MediaCapabilities';
badgesContainer.appendChild(badge);
}
// Add encoder/decoder badges with specific API info
if (info.canEncode) {
const badge = dom.create('span');
badge.className = 'badge badge-encoder';
badge.textContent = 'Encoder';
badgesContainer.appendChild(badge);
}
if (info.canDecode) {
const badge = dom.create('span');
badge.className = 'badge badge-decoder';
badge.textContent = 'Decoder';
badgesContainer.appendChild(badge);
}
// Create the details container for more specific information
const details = dom.create('div');
details.className = 'details';
// Add more specific hardware acceleration info
if (info.webcodecConfig && info.webcodecConfig.encoder && info.webcodecConfig.encoder.hardwareAcceleration === 'prefer-hardware') {
const hwEncBadge = dom.create('span');
hwEncBadge.className = 'badge badge-hw';
hwEncBadge.textContent = 'HW Encoder';
details.appendChild(hwEncBadge);
}
if (info.webcodecConfig && info.webcodecConfig.decoder && info.webcodecConfig.decoder.hardwareAcceleration === 'prefer-hardware') {
const hwDecBadge = dom.create('span');