diff --git a/server/services/rtsp-camera/lib/getImage.js b/server/services/rtsp-camera/lib/getImage.js index 63932ab8e5..ea5bbd8130 100644 --- a/server/services/rtsp-camera/lib/getImage.js +++ b/server/services/rtsp-camera/lib/getImage.js @@ -41,6 +41,12 @@ async function getImage(device) { const args = ['-i', cameraUrlParam.value, '-f', 'image2', '-vframes', '1', '-qscale:v', '15']; + // For rtsp protocol, add tcp transport to avoid green band of pixels) + if (cameraUrlParam.value.includes('rtsp')) { + args.push('-rtsp_transport'); + args.push('tcp'); + } + args.push('-vf'); switch (cameraRotationParam.value) { case DEVICE_ROTATION.DEGREES_90: diff --git a/server/test/services/rtsp-camera/rtspCamera.test.js b/server/test/services/rtsp-camera/rtspCamera.test.js index 3ca9eef186..13618fa3c6 100644 --- a/server/test/services/rtsp-camera/rtspCamera.test.js +++ b/server/test/services/rtsp-camera/rtspCamera.test.js @@ -20,6 +20,21 @@ const device = { ], }; +const deviceWithRtspImage = { + id: 'a6fb4cb8-ccc2-4234-a752-b25d1eb5ab6b', + selector: 'my-camera', + params: [ + { + name: 'CAMERA_URL', + value: 'rtsp://test.fr/test', + }, + { + name: 'CAMERA_ROTATION', + value: '0', + }, + ], +}; + const gladys = { config: { tempFolder: '/tmp/gladys', @@ -141,6 +156,10 @@ describe('RtspCameraManager commands', () => { const image = await rtspCameraManager.getImage(device); expect(image).to.equal('image/jpg;base64,aW1hZ2U='); }); + it('should getImage with RTSP url', async () => { + const image = await rtspCameraManager.getImage(deviceWithRtspImage); + expect(image).to.equal('image/jpg;base64,aW1hZ2U='); + }); it('should getImage 90°', async () => { const image = await rtspCameraManager.getImage(deviceRotation90); expect(image).to.equal('image/jpg;base64,aW1hZ2U=');