noobs 0.0.178 → 0.0.180

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/noobs.node CHANGED
Binary file
package/index.d.ts CHANGED
@@ -158,6 +158,11 @@ export type SourceDimensions = {
158
158
  width: number; // Width in pixels, before scaling
159
159
  };
160
160
 
161
+ export enum FileExtension {
162
+ MP4,
163
+ MKV,
164
+ }
165
+
161
166
  interface Noobs {
162
167
  Init(
163
168
  distPath: string,
@@ -174,7 +179,7 @@ interface Noobs {
174
179
  StopRecording(): void;
175
180
  ForceStopRecording(): void;
176
181
  GetLastRecording(): string;
177
- SetRecordingDir(recordingPath: string): void;
182
+ SetRecordingCfg(recordingPath: string, fileExtension: FileExtension): void;
178
183
  ResetVideoContext(fps: number, width: number, height: number): void;
179
184
 
180
185
  // Encoder functions.
package/index.js CHANGED
@@ -1,9 +1,21 @@
1
1
  const path = require('path');
2
2
 
3
- process.env.Path = path
3
+ // Path to the OBS binaries. We want this to come first so that the correct
4
+ // DLLs are loaded. It's possible other copies are on the system PATH already.
5
+ let binPath = path
4
6
  .resolve(__dirname, 'dist', 'bin')
5
7
  .replace('app.asar', 'app.asar.unpacked');
6
8
 
9
+ if (process.env.PATH) {
10
+ // Almost certainly there is an existing PATH. We don't want to drop
11
+ // things off the path as it might make other things fail.
12
+ binPath += ';';
13
+ binPath += process.env.PATH;
14
+ }
15
+
16
+ // Now set the updated PATH for this process.
17
+ process.env.Path = binPath;
18
+
7
19
  const packageName = 'noobs.node';
8
20
  const noobs = require(`./dist/${packageName}`);
9
- module.exports = noobs;
21
+ module.exports = noobs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noobs",
3
- "version": "0.0.178",
3
+ "version": "0.0.180",
4
4
  "description": "A native Node.js addon with libobs bindings for Warcraft Recorder.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/src/main.cpp CHANGED
@@ -37,22 +37,34 @@ Napi::Value ObsShutdown(const Napi::CallbackInfo& info) {
37
37
  return info.Env().Undefined();
38
38
  }
39
39
 
40
- Napi::Value ObsSetRecordingDir(const Napi::CallbackInfo& info) {
40
+ Napi::Value ObsSetRecordingCfg(const Napi::CallbackInfo& info) {
41
41
  if (!obs) {
42
- blog(LOG_ERROR, "ObsSetRecordingDir called but obs is not initialized");
42
+ blog(LOG_ERROR, "ObsSetRecordingCfg called but obs is not initialized");
43
43
  Napi::Error::New(info.Env(), "Obs not initialized").ThrowAsJavaScriptException();
44
44
  return info.Env().Undefined();
45
45
  }
46
46
 
47
- bool valid = info.Length() == 1 && info[0].IsString();
47
+ bool valid = info.Length() == 2 && info[0].IsString() && info[1].IsNumber();
48
48
 
49
49
  if (!valid) {
50
- Napi::TypeError::New(info.Env(), "Invalid arguments passed to ObsSetRecordingDir").ThrowAsJavaScriptException();
50
+ Napi::TypeError::New(info.Env(), "Invalid arguments passed to ObsSetRecordingCfg").ThrowAsJavaScriptException();
51
51
  return info.Env().Undefined();
52
52
  }
53
53
 
54
54
  std::string recordingPath = info[0].As<Napi::String>().Utf8Value();
55
- obs->setRecordingDir(recordingPath);
55
+ int fileExt = info[1].As<Napi::Number>().Int32Value();
56
+ std::string fileExtension;
57
+
58
+ if (fileExt == 0) {
59
+ fileExtension = "mp4";
60
+ } else if (fileExt == 1) {
61
+ fileExtension = "mkv";
62
+ } else {
63
+ Napi::TypeError::New(info.Env(), "Invalid file extension value").ThrowAsJavaScriptException();
64
+ return info.Env().Undefined();
65
+ }
66
+
67
+ obs->setRecordingCfg(recordingPath, fileExtension);
56
68
  return info.Env().Undefined();
57
69
  }
58
70
 
@@ -665,7 +677,7 @@ Napi::Value ObsGetDrawSourceOutlineEnabled(const Napi::CallbackInfo& info) {
665
677
  Napi::Object Init(Napi::Env env, Napi::Object exports) {
666
678
  exports.Set("Init", Napi::Function::New(env, ObsInit));
667
679
  exports.Set("Shutdown", Napi::Function::New(env, ObsShutdown));
668
- exports.Set("SetRecordingDir", Napi::Function::New(env, ObsSetRecordingDir));
680
+ exports.Set("SetRecordingCfg", Napi::Function::New(env, ObsSetRecordingCfg));
669
681
  exports.Set("ResetVideoContext", Napi::Function::New(env, ObsResetVideoContext));
670
682
  exports.Set("ListVideoEncoders", Napi::Function::New(env, ObsListVideoEncoders));
671
683
  exports.Set("SetVideoEncoder", Napi::Function::New(env, ObsSetVideoEncoder));
@@ -262,11 +262,11 @@ void ObsInterface::create_output() {
262
262
  obs_data_set_int(settings, "max_size_mb", 1024);
263
263
  obs_data_set_string(settings, "directory", recording_path.c_str());
264
264
  obs_data_set_string(settings, "format", "%CCYY-%MM-%DD %hh-%mm-%ss");
265
- obs_data_set_string(settings, "extension", "mp4");
265
+ obs_data_set_string(settings, "extension", file_extension.c_str());
266
266
  } else {
267
267
  blog(LOG_INFO, "Set ffmpeg_muxer settings");
268
268
  // Need to specify the exact path for ffmpeg_muxer. We will write this again at start recording.
269
- std::string filename = recording_path + "\\" + get_current_date_time() + ".mp4";
269
+ std::string filename = recording_path + "\\" + get_current_date_time() + "." + file_extension;
270
270
  obs_data_set_string(settings, "path", filename.c_str());
271
271
  unbuffered_output_filename = filename;
272
272
  }
@@ -276,8 +276,14 @@ void ObsInterface::create_output() {
276
276
  connect_signal_handlers(output);
277
277
  }
278
278
 
279
- void ObsInterface::setRecordingDir(const std::string& recordingPath) {
280
- blog(LOG_INFO, "Set recording directory. Path: %s", recordingPath.c_str());
279
+ void ObsInterface::setRecordingCfg(
280
+ const std::string& recordingPath,
281
+ const std::string& fileExtension
282
+ ) {
283
+ blog(LOG_INFO, "Set recording config. Path: %s. Ext %s",
284
+ recordingPath.c_str(),
285
+ fileExtension.c_str()
286
+ );
281
287
 
282
288
  if (obs_output_active(output)) {
283
289
  blog(LOG_ERROR, "Output is active, cannot update recording path");
@@ -285,12 +291,14 @@ void ObsInterface::setRecordingDir(const std::string& recordingPath) {
285
291
  }
286
292
 
287
293
  recording_path = recordingPath;
294
+ file_extension = fileExtension;
288
295
  create_output();
289
296
 
290
297
  create_video_encoders();
291
298
  create_audio_encoders();
292
299
  }
293
300
 
301
+
294
302
  void ObsInterface::create_video_encoders() {
295
303
  blog(LOG_INFO, "Set video encoder: %s", video_encoder_id.c_str());
296
304
 
@@ -1099,7 +1107,7 @@ void ObsInterface::startRecording(int offset) {
1099
1107
  }
1100
1108
  } else {
1101
1109
  obs_data_t *ffmpeg_settings = obs_data_create();
1102
- std::string filename = recording_path + "\\" + get_current_date_time() + ".mp4";
1110
+ std::string filename = recording_path + "\\" + get_current_date_time() + "." + file_extension;
1103
1111
  obs_data_set_string(ffmpeg_settings, "path", filename.c_str());
1104
1112
  obs_output_update(output, ffmpeg_settings);
1105
1113
  obs_data_release(ffmpeg_settings);
@@ -52,7 +52,7 @@ class ObsInterface {
52
52
  void forceStopRecording(); // Force stop the recording, this will not save the current recording.
53
53
  std::string getLastRecording(); // Get the last recorded file path.
54
54
  void setBuffering(bool buffer); // Enable or disable buffering.
55
- void setRecordingDir(const std::string& recordingPath); // Set the recording path.
55
+ void setRecordingCfg(const std::string& recordingPath, const std::string& fileExtension); // Set the recording path.
56
56
  void setVideoContext(int fps, int width, int height); // Reset video settings.
57
57
 
58
58
  std::string createSource(std::string name, std::string type); // Create a new source, returns the name of the source which can vary from the requested.
@@ -105,6 +105,7 @@ class ObsInterface {
105
105
  Napi::ThreadSafeFunction jscb; // javascript callback
106
106
  std::string recording_path = "";
107
107
  std::string unbuffered_output_filename = "";
108
+ std::string file_extension = "mp4"; // File extension for recordings.
108
109
 
109
110
  bool buffering = false; // Whether we are buffering the recording in memory.
110
111
  bool drawSourceOutline = false; // Draw red outline around source