Skip to content

Commit 994cdd0

Browse files
committed
Tweak videoFilters and inactive timeout
1 parent d3b1ee6 commit 994cdd0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/streamingDelegate.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export class StreamingDelegate implements CameraStreamingDelegate {
129129
}
130130

131131
private determineResolution(request: SnapshotRequest | VideoInfo, isSnapshot = false): ResolutionInfo {
132-
let width = request.width;
133-
let height = request.height;
132+
let width = Math.floor(request.width / 2) * 2;
133+
let height = Math.floor(request.height / 2) * 2;
134134
if (!isSnapshot) {
135135
if ((this.videoConfig.forceMax && this.videoConfig.maxWidth) ||
136136
(request.width > this.videoConfig.maxWidth)) {
@@ -151,7 +151,9 @@ export class StreamingDelegate implements CameraStreamingDelegate {
151151
vf.push('scale=' + (width > 0 ? '\'min(' + width + ',iw)\'' : 'iw') + ':' +
152152
(height > 0 ? '\'min(' + height + ',ih)\'' : 'ih') +
153153
(this.videoConfig.preserveRatio ? ':force_original_aspect_ratio=decrease' : ''));
154-
vf.push('scale=trunc(iw/2)*2:trunc(ih/2)*2'); // Force to fit encoder restrictions
154+
if (this.videoConfig.preserveRatio) {
155+
vf.push('scale=trunc(iw/2)*2:trunc(ih/2)*2'); // Force to fit encoder restrictions
156+
}
155157
}
156158
}
157159

@@ -334,7 +336,7 @@ export class StreamingDelegate implements CameraStreamingDelegate {
334336
' -f null' +
335337
' -ar ' + request.audio.sample_rate + 'k' +
336338
' -b:a ' + request.audio.max_bit_rate + 'k' +
337-
' -ac 1' +
339+
' -ac ' + request.audio.channel +
338340
' -payload_type ' + request.audio.pt;
339341

340342
ffmpegArgs += // Audio Stream
@@ -363,10 +365,10 @@ export class StreamingDelegate implements CameraStreamingDelegate {
363365
}
364366
activeSession.timeout = setTimeout(() => {
365367
activeSession.socket?.close();
366-
this.log.info('Device appears to be inactive for over 5 seconds. Stopping stream.', this.cameraName);
368+
this.log.info('Device appears to be inactive. Stopping stream.', this.cameraName);
367369
this.controller.forceStopStreamingSession(request.sessionID);
368370
this.stopStream(request.sessionID);
369-
}, 5000);
371+
}, request.video.rtcp_interval * 2 * 1000);
370372
});
371373
activeSession.socket.bind(sessionInfo.videoReturnPort, sessionInfo.localAddress);
372374

0 commit comments

Comments
 (0)