-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathvariables.js
157 lines (150 loc) · 6.53 KB
/
variables.js
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
export function getVariables() {
const variables = []
variables.push(
{ variableId: 'base_resolution', name: 'Current base (canvas) resolution' },
{ variableId: 'output_resolution', name: 'Current output (scaled) resolution' },
{ variableId: 'target_framerate', name: 'Current profile framerate' },
{ variableId: 'fps', name: 'Current actual framerate' },
{ variableId: 'cpu_usage', name: 'Current CPU usage (percentage)' },
{ variableId: 'memory_usage', name: 'Current RAM usage (in megabytes)' },
{ variableId: 'free_disk_space', name: 'Free recording disk space' },
{ variableId: 'free_disk_space_mb', name: 'Free recording disk space in MB, with no unit text' },
{ variableId: 'render_missed_frames', name: 'Number of frames missed due to rendering lag' },
{ variableId: 'render_total_frames', name: 'Number of frames rendered' },
{ variableId: 'output_skipped_frames', name: 'Number of encoder frames skipped' },
{ variableId: 'output_total_frames', name: 'Number of total encoder frames' },
{ variableId: 'average_frame_time', name: 'Average frame time (in milliseconds)' },
{ variableId: 'recording', name: 'Recording State' },
{ variableId: 'recording_file_name', name: 'File name of the last completed recording' },
{ variableId: 'recording_path', name: 'File path of current recording' },
{ variableId: 'recording_timecode', name: 'Recording timecode' },
{ variableId: 'stream_timecode', name: 'Stream Timecode' },
{ variableId: 'stream_service', name: 'Stream Service' },
{ variableId: 'streaming', name: 'Streaming State' },
{ variableId: 'kbits_per_sec', name: 'Stream output in kilobits per second' },
{ variableId: 'scene_active', name: 'Current active scene' },
{ variableId: 'scene_preview', name: 'Current preview scene' },
{ variableId: 'scene_previous', name: 'Previously active scene, before the current scene' },
{ variableId: 'profile', name: 'Current profile' },
{ variableId: 'scene_collection', name: 'Current scene collection' },
{ variableId: 'current_transition', name: 'Current transition' },
{ variableId: 'transition_duration', name: 'Current transition duration' },
{ variableId: 'transition_active', name: 'Transition in progress' },
{ variableId: 'current_media_name', name: 'Source name for currently playing media source' },
{ variableId: 'current_media_time_elapsed', name: 'Time elapsed for currently playing media source' },
{
variableId: 'current_media_time_remaining',
name: 'Time remaining for currently playing media source',
},
{ variableId: 'replay_buffer_path', name: 'File path of the last replay buffer saved' },
{
variableId: 'custom_command_type',
name: 'Latest Custom Command type sent to obs-websocket',
},
{
variableId: 'custom_command_request',
name: 'Latest Custom Command request data sent to obs-websocket',
},
{
variableId: 'custom_command_response',
name: 'Latest response from obs-websocket after using the Custom Command action',
},
{
variableId: 'vendor_event_name',
name: 'Vendor name of the latest Vendor Event received from obs-websocket',
},
{
variableId: 'vendor_event_type',
name: 'Latest Vendor Event type received from obs-websocket',
},
{
variableId: 'vendor_event_data',
name: 'Latest Vendor Event data received from obs-websocket',
},
)
//Defaults
this.setVariableValues({
current_media_name: 'None',
recording_file_name: 'None',
replay_buffer_path: 'None',
current_media_time_elapsed: '--:--:--',
current_media_time_remaining: '--:--:--',
scene_preview: this.states.previewScene ?? 'None',
scene_active: this.states.programScene ?? 'None',
scene_previous: this.states.previousScene ?? 'None',
})
//Source Specific Variables
for (let s in this.sources) {
let source = this.sources[s]
let sourceName = source.validName ? source.validName : this.validName(source.sourceName)
let inputSettings = source.settings
if (source.inputKind) {
switch (source.inputKind) {
case 'text_ft2_source_v2':
case 'text_gdiplus_v2':
case 'text_gdiplus_v3':
variables.push({ variableId: `current_text_${sourceName}`, name: `${sourceName} - Current text` })
if (inputSettings?.from_file || inputSettings?.read_from_file) {
this.setVariableValues({
[`current_text_${sourceName}`]: `Text from file: ${inputSettings.text_file ?? inputSettings.file}`,
})
} else if (inputSettings?.text) {
this.setVariableValues({
[`current_text_${sourceName}`]: inputSettings.text ?? '',
})
}
break
case 'ffmpeg_source':
case 'vlc_source':
variables.push(
{ variableId: `media_status_${sourceName}`, name: `${sourceName} - Media status` },
{ variableId: `media_file_name_${sourceName}`, name: `${sourceName} - Media file name` },
{ variableId: `media_time_elapsed_${sourceName}`, name: `${sourceName} - Time elapsed` },
{ variableId: `media_time_remaining_${sourceName}`, name: `${sourceName} - Time remaining` },
)
let file = ''
if (inputSettings?.playlist) {
file = inputSettings?.playlist[0]?.value?.match(/[^\\\/]+(?=\.[\w]+$)|[^\\\/]+$/)
//Use first value in playlist until support for determining currently playing cue
} else if (inputSettings?.local_file) {
file = inputSettings?.local_file?.match(/[^\\\/]+(?=\.[\w]+$)|[^\\\/]+$/)
}
this.setVariableValues({ [`media_file_name_${sourceName}`]: file })
break
case 'image_source':
variables.push({
variableId: `image_file_name_${sourceName}`,
name: `${sourceName} - Image file name`,
})
this.setVariableValues({
[`image_file_name_${sourceName}`]: source.inputSettings?.file
? source.inputSettings?.file?.match(/[^\\\/]+(?=\.[\w]+$)|[^\\\/]+$/)
: '',
})
break
default:
break
}
}
if (source.inputAudioTracks) {
variables.push(
{ variableId: `volume_${sourceName}`, name: `${sourceName} - Volume` },
{ variableId: `mute_${sourceName}`, name: `${sourceName} - Mute status` },
{ variableId: `monitor_${sourceName}`, name: `${sourceName} - Audio monitor` },
{ variableId: `sync_offset_${sourceName}`, name: `${sourceName} - Sync offset` },
{ variableId: `balance_${sourceName}`, name: `${sourceName} - Audio balance` },
)
}
}
//Scene Variables
let sceneIndex = 0
for (let s = this.scenes?.length - 1; s >= 0; s--) {
let index = ++sceneIndex
let sceneName = this.scenes[s].sceneName
variables.push({ variableId: `scene_${index}`, name: `Scene - ${index}` })
this.setVariableValues({
[`scene_${index}`]: sceneName,
})
}
return variables
}