noobs 0.0.179 → 0.0.181
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 +0 -0
- package/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/main.cpp +13 -6
- package/src/obs_interface.cpp +13 -5
- package/src/obs_interface.h +2 -1
package/dist/noobs.node
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ export type SourceDimensions = {
|
|
|
158
158
|
width: number; // Width in pixels, before scaling
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
export type FileExtension = 'mp4' | 'mkv';
|
|
162
|
+
|
|
161
163
|
interface Noobs {
|
|
162
164
|
Init(
|
|
163
165
|
distPath: string,
|
|
@@ -174,7 +176,7 @@ interface Noobs {
|
|
|
174
176
|
StopRecording(): void;
|
|
175
177
|
ForceStopRecording(): void;
|
|
176
178
|
GetLastRecording(): string;
|
|
177
|
-
|
|
179
|
+
SetRecordingCfg(recordingPath: string, fileExtension: FileExtension): void;
|
|
178
180
|
ResetVideoContext(fps: number, width: number, height: number): void;
|
|
179
181
|
|
|
180
182
|
// Encoder functions.
|
package/package.json
CHANGED
package/src/main.cpp
CHANGED
|
@@ -37,22 +37,29 @@ Napi::Value ObsShutdown(const Napi::CallbackInfo& info) {
|
|
|
37
37
|
return info.Env().Undefined();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
Napi::Value
|
|
40
|
+
Napi::Value ObsSetRecordingCfg(const Napi::CallbackInfo& info) {
|
|
41
41
|
if (!obs) {
|
|
42
|
-
blog(LOG_ERROR, "
|
|
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() ==
|
|
47
|
+
bool valid = info.Length() == 2 && info[0].IsString() && info[1].IsString();
|
|
48
48
|
|
|
49
49
|
if (!valid) {
|
|
50
|
-
Napi::TypeError::New(info.Env(), "Invalid arguments passed to
|
|
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
|
-
|
|
55
|
+
std::string fileExtension = info[1].As<Napi::String>().Utf8Value();
|
|
56
|
+
|
|
57
|
+
if (fileExtension != "mp4" && fileExtension != "mkv") {
|
|
58
|
+
Napi::TypeError::New(info.Env(), "Invalid file extension value").ThrowAsJavaScriptException();
|
|
59
|
+
return info.Env().Undefined();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
obs->setRecordingCfg(recordingPath, fileExtension);
|
|
56
63
|
return info.Env().Undefined();
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -665,7 +672,7 @@ Napi::Value ObsGetDrawSourceOutlineEnabled(const Napi::CallbackInfo& info) {
|
|
|
665
672
|
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
666
673
|
exports.Set("Init", Napi::Function::New(env, ObsInit));
|
|
667
674
|
exports.Set("Shutdown", Napi::Function::New(env, ObsShutdown));
|
|
668
|
-
exports.Set("
|
|
675
|
+
exports.Set("SetRecordingCfg", Napi::Function::New(env, ObsSetRecordingCfg));
|
|
669
676
|
exports.Set("ResetVideoContext", Napi::Function::New(env, ObsResetVideoContext));
|
|
670
677
|
exports.Set("ListVideoEncoders", Napi::Function::New(env, ObsListVideoEncoders));
|
|
671
678
|
exports.Set("SetVideoEncoder", Napi::Function::New(env, ObsSetVideoEncoder));
|
package/src/obs_interface.cpp
CHANGED
|
@@ -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",
|
|
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() + ".
|
|
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::
|
|
280
|
-
|
|
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() + ".
|
|
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);
|
package/src/obs_interface.h
CHANGED
|
@@ -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
|
|
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
|