noobs 0.0.187 → 0.0.190
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/README.md +2 -0
- package/dist/noobs.node +0 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/main.cpp +23 -0
- package/src/obs_interface.cpp +16 -0
- package/src/obs_interface.h +2 -0
package/README.md
CHANGED
package/dist/noobs.node
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ interface Noobs {
|
|
|
171
171
|
|
|
172
172
|
// Recording functions.
|
|
173
173
|
SetBuffering(buffering: boolean): void; // In buffering mode, the recording is stored in memory and can be converted to a file later.
|
|
174
|
+
SetFragmentation(fragmented: boolean): void; // Use fragmented MP4.
|
|
174
175
|
StartBuffer(): void;
|
|
175
176
|
StartRecording(offset: number): void;
|
|
176
177
|
StopRecording(): void;
|
package/package.json
CHANGED
package/src/main.cpp
CHANGED
|
@@ -156,6 +156,28 @@ Napi::Value ObsSetBuffering(const Napi::CallbackInfo& info) {
|
|
|
156
156
|
return info.Env().Undefined();
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
Napi::Value ObsSetFragmentation(const Napi::CallbackInfo& info) {
|
|
160
|
+
blog(LOG_INFO, "ObsSetFragmentation called");
|
|
161
|
+
|
|
162
|
+
if (!obs) {
|
|
163
|
+
blog(LOG_ERROR, "ObsSetFragmentation called but obs is not initialized");
|
|
164
|
+
Napi::Error::New(info.Env(), "Obs not initialized").ThrowAsJavaScriptException();
|
|
165
|
+
return info.Env().Undefined();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
bool valid = info.Length() == 1 && info[0].IsBoolean();
|
|
169
|
+
|
|
170
|
+
if (!valid) {
|
|
171
|
+
Napi::TypeError::New(info.Env(), "Invalid arguments passed to ObsSetFragmentation").ThrowAsJavaScriptException();
|
|
172
|
+
return info.Env().Undefined();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
bool fragmented = info[0].As<Napi::Boolean>().Value();
|
|
176
|
+
obs->setFragmentation(fragmented);
|
|
177
|
+
|
|
178
|
+
return info.Env().Undefined();
|
|
179
|
+
}
|
|
180
|
+
|
|
159
181
|
Napi::Value ObsStartBuffer(const Napi::CallbackInfo& info) {
|
|
160
182
|
blog(LOG_INFO, "ObsStartBuffer called");
|
|
161
183
|
|
|
@@ -678,6 +700,7 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
678
700
|
exports.Set("SetVideoEncoder", Napi::Function::New(env, ObsSetVideoEncoder));
|
|
679
701
|
|
|
680
702
|
exports.Set("SetBuffering", Napi::Function::New(env, ObsSetBuffering));
|
|
703
|
+
exports.Set("SetFragmentation", Napi::Function::New(env, ObsSetFragmentation));
|
|
681
704
|
exports.Set("StartBuffer", Napi::Function::New(env, ObsStartBuffer));
|
|
682
705
|
exports.Set("StartRecording", Napi::Function::New(env, ObsStartRecording));
|
|
683
706
|
exports.Set("StopRecording", Napi::Function::New(env, ObsStopRecording));
|
package/src/obs_interface.cpp
CHANGED
|
@@ -271,6 +271,12 @@ void ObsInterface::create_output() {
|
|
|
271
271
|
unbuffered_output_filename = filename;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
if (fragmented && file_extension == "mp4") {
|
|
275
|
+
blog(LOG_INFO, "Fragmentation enabled");
|
|
276
|
+
std::string mux_frag = "movflags=frag_keyframe+empty_moov+delay_moov";
|
|
277
|
+
obs_data_set_string(settings, "muxer_settings", mux_frag.c_str());
|
|
278
|
+
}
|
|
279
|
+
|
|
274
280
|
obs_output_update(output, settings);
|
|
275
281
|
obs_data_release(settings);
|
|
276
282
|
connect_signal_handlers(output);
|
|
@@ -1047,6 +1053,16 @@ void ObsInterface::setBuffering(bool value) {
|
|
|
1047
1053
|
create_output();
|
|
1048
1054
|
}
|
|
1049
1055
|
|
|
1056
|
+
void ObsInterface::setFragmentation(bool value) {
|
|
1057
|
+
if (obs_output_active(output)) {
|
|
1058
|
+
blog(LOG_ERROR, "Cannot change fragmentation state while output is active");
|
|
1059
|
+
throw new std::runtime_error("Cannot change fragmentation state while output is active");
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
fragmented = value;
|
|
1063
|
+
create_output();
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1050
1066
|
void ObsInterface::startBuffering() {
|
|
1051
1067
|
blog(LOG_INFO, "ObsInterface::startBuffering called");
|
|
1052
1068
|
|
package/src/obs_interface.h
CHANGED
|
@@ -52,6 +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 setFragmentation(bool fragmented); // Enable or disable fragmented MP4.
|
|
55
56
|
void setRecordingCfg(const std::string& recordingPath, const std::string& fileExtension); // Set the recording path.
|
|
56
57
|
void setVideoContext(int fps, int width, int height); // Reset video settings.
|
|
57
58
|
|
|
@@ -108,6 +109,7 @@ class ObsInterface {
|
|
|
108
109
|
std::string file_extension = "mp4"; // File extension for recordings.
|
|
109
110
|
|
|
110
111
|
bool buffering = false; // Whether we are buffering the recording in memory.
|
|
112
|
+
bool fragmented = false; // Use fragmented MP4.
|
|
111
113
|
bool drawSourceOutline = false; // Draw red outline around source
|
|
112
114
|
void init_obs(const std::string& distPath);
|
|
113
115
|
int reset_video(int fps, int width, int height);
|