Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera: Add TCP transport for RTSP stream #2150

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions server/services/rtsp-camera/lib/getImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions server/test/services/rtsp-camera/rtspCamera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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=');
Expand Down
Loading