rebroadcast: use highwatermark for nvr perf improvement

This commit is contained in:
Koushik Dutta
2023-05-11 10:20:28 -07:00
parent 3893ccd776
commit 90c9efc8a6
3 changed files with 9 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.86",
"version": "0.9.87",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.86",
"version": "0.9.87",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.86",
"version": "0.9.87",
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -4,6 +4,8 @@ import fs from 'fs';
import { format } from "path";
import { Duplex } from "stream";
const highWaterMark = 1024 * 1024;
// non standard extension that dumps the rtp payload to a file.
export class FileRtspServer extends RtspServer {
writeStream: fs.WriteStream;
@@ -56,6 +58,7 @@ export class FileRtspServer extends RtspServer {
await fs.promises.rename(truncate, file);
truncateWriteStream = fs.createWriteStream(undefined, {
fd,
highWaterMark,
})
// this.writeConsole?.log('truncating', truncate);
}
@@ -72,7 +75,9 @@ export class FileRtspServer extends RtspServer {
this.cleanup();
this.segmentBytesWritten = 0;
this.writeStream = truncateWriteStream || fs.createWriteStream(file);
this.writeStream = truncateWriteStream || fs.createWriteStream(file, {
highWaterMark,
});
this.writeStream.on('error', e => {
this.writeConsole?.error('RTSP WRITE error', e);
});