群晖利用API对接入surveillance中的摄像头进行抓图

前言:
Surveillance Station 是一款专业的网络视频录制 (NVR) 套件,与 DiskStation Manager (DSM) 随附在一起。您可配合已有的监控设备使用 Surveillance Station 以获得情境感知,让您作出知情决定,以有效保护您的家庭或办公室环境。有许多强大的监控功能,包括:

  • 远程录制和监控与 Synology NAS 配对的网络摄像机拍摄的实时视频片段
  • 通过网页浏览器和移动设备方便观看录制的视频片段
  • 设置自动录制计划
  • 探测潜在的可疑行为并接收自动报警通知
  • 与 Axis Door Controller 接合监控进/出口区域
  • 轻松搜索和检查生成的所有监控日志

界面:

流程说明:
其实我的node-red已经集成了ffmpeg,可以通过ffmpeg利用rtsp流抓图,最近玩大佬搞的百度人脸识别,发现这种抓图方式不方便在NR直接输出成二进制缓存文件,摄像头不支持http方式抓图,于是就想到了群晖,于是到群晖官方把对应的API开发手册扒拉下来学习一下,就有了现在这个教程。这个只是用来抛砖引玉而已,有兴趣的可以利用它结合其它功能玩起来。

[mw_shl_code=applescript,true]{“id”:“c90adddb.d6755”,“type”:“tab”,“label”:“流程2”,“disabled”:false,“info”:""},{“id”:“261876ee.ac1b3a”,“type”:“image”,“z”:“c90adddb.d6755”,“name”:"",“width”:“200”,“x”:860,“y”:300,“wires”:]},{“id”:“ef2ae600.814a78”,“type”:“www-request”,“z”:“c90adddb.d6755”,“name”:“获取sid”,“method”:“GET”,“ret”:“obj”,“url”:"",“follow-redirects”:true,“persistent-http”:true,“tls”:"",“x”:420,“y”:220,“wires”:“fe2af5a0.8f12f8”]],“inputLabels”:“输入”],“outputLabels”:“输出”]},{“id”:“d966d820.cef1f8”,“type”:“change”,“z”:“c90adddb.d6755”,“name”:“设置群辉用户名、密码、摄像头ID”,“rules”:{“t”:“set”,“p”:“dsm_account”,“pt”:“msg”,“to”:“用户名”,“tot”:“str”},{“t”:“set”,“p”:“dsm_passwd”,“pt”:“msg”,“to”:“密码”,“tot”:“str”},{“t”:“set”,“p”:“dsm_camera_id”,“pt”:“msg”,“to”:“摄像头ID(纯数字,你选第几个就输入对应数字,比如1)”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:380,“y”:160,“wires”:“dc4700b0.16ac1”]]},{“id”:“52d8e4c9.d6ab0c”,“type”:“www-request”,“z”:“c90adddb.d6755”,“name”:“GetSnapshot”,“method”:“GET”,“ret”:“bin”,“url”:"",“follow-redirects”:true,“persistent-http”:true,“tls”:"",“x”:610,“y”:300,“wires”:“261876ee.ac1b3a”]]},{“id”:“dc4700b0.16ac1”,“type”:“function”,“z”:“c90adddb.d6755”,“name”:“url_sid”,“func”:“msg.url = “http://群晖IP:端口/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=”+msg.dsm_account+”&passwd="+msg.dsm_passwd+"&session=SurveillanceStation&format=sid";\nreturn msg;",“outputs”:1,“noerr”:0,“x”:610,“y”:160,“wires”:“ef2ae600.814a78”]]},{“id”:“f22b7cf9.77944”,“type”:“function”,“z”:“c90adddb.d6755”,“name”:“url_snapshot”,“func”:“var sid;\nsid = msg.payload.data.sid;\nmsg.url = ‘http://群晖IP:端口/webapi/entry.cgi?version=9&id=’+msg.dsm_camera_id+’&api=“SYNO.SurveillanceStation.Camera”&method=“GetSnapshot”&profileType=0&_sid=’+sid;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:410,“y”:300,“wires”:“52d8e4c9.d6ab0c”]]},{“id”:“fe2af5a0.8f12f8”,“type”:“switch”,“z”:“c90adddb.d6755”,“name”:"",“property”:“payload.error.code”,“propertyType”:“msg”,“rules”:{“t”:“nnull”},{“t”:“else”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:130,“y”:220,“wires”:“ef2ae600.814a78”],“f22b7cf9.77944”]],“inputLabels”:“输入”]},{“id”:“bd81c963.430a38”,“type”:“inject”,“z”:“c90adddb.d6755”,“name”:"",“topic”:"",“payload”:"",“payloadType”:“date”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:100,“y”:160,“wires”:“d966d820.cef1f8”]]}][/mw_shl_code]

1 个赞

测试有效。

大佬,导入失败呀

可以给个文件不

折腾了一晚上,一个节点一个节点添加然后改成一样的,也去看了下文档,郁闷。。上传不了文件。

    {
        "id": "3102625a.ead99e",
        "type": "tab",
        "label": "流程2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "492ff094.4005f",
        "type": "inject",
        "z": "3102625a.ead99e",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 210,
        "y": 140,
        "wires": [
            [
                "a82a7f1a.22a1e"
            ]
        ]
    },
    {
        "id": "a82a7f1a.22a1e",
        "type": "change",
        "z": "3102625a.ead99e",
        "name": "account、password、cameraID",
        "rules": [
            {
                "t": "set",
                "p": "dsm_account",
                "pt": "msg",
                "to": "nodered",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_passwd",
                "pt": "msg",
                "to": "passwd",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "dsm_camera_id",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 480,
        "y": 140,
        "wires": [
            [
                "b5c244a9.d9b4c8"
            ]
        ]
    },
    {
        "id": "b5c244a9.d9b4c8",
        "type": "function",
        "z": "3102625a.ead99e",
        "name": "url_sid",
        "func": "msg.url = \"http://192.168.3.98:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=\"+msg.dsm_account+\"&passwd=\"+msg.dsm_passwd+\"&session=SurveillanceStation&format=sid\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 740,
        "y": 140,
        "wires": [
            [
                "e489a75e.10c308",
                "b4a92270.b3ab9"
            ]
        ]
    },
    {
        "id": "189114b2.1b841b",
        "type": "switch",
        "z": "3102625a.ead99e",
        "name": "",
        "property": "payload.error.code",
        "propertyType": "msg",
        "rules": [
            {
                "t": "nnull"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 150,
        "y": 220,
        "wires": [
            [
                "b4a92270.b3ab9"
            ],
            [
                "58e906a3.0c19f8"
            ]
        ]
    },
    {
        "id": "58e906a3.0c19f8",
        "type": "function",
        "z": "3102625a.ead99e",
        "name": "url_snapshot",
        "func": "var sid;\nsid = msg.payload.data.sid;\nmsg.url = 'http://192.168.3.98:5000/webapi/entry.cgi?version=9&id='+msg.dsm_camera_id+'&api=\"SYNO.SurveillanceStation.Camera\"&method=\"GetSnapshot\"&profileType=0&_sid=\"'+sid+'\"';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 400,
        "y": 340,
        "wires": [
            [
                "e8d550dc.bb719",
                "e489a75e.10c308"
            ]
        ]
    },
    {
        "id": "d201d8cd.7f2468",
        "type": "image",
        "z": "3102625a.ead99e",
        "name": "",
        "width": 160,
        "data": "payload",
        "dataType": "msg",
        "thumbnail": false,
        "active": false,
        "x": 880,
        "y": 340,
        "wires": []
    },
    {
        "id": "b4a92270.b3ab9",
        "type": "www-request",
        "z": "3102625a.ead99e",
        "name": "",
        "method": "GET",
        "ret": "obj",
        "url": "",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 410,
        "y": 220,
        "wires": [
            [
                "189114b2.1b841b",
                "182d1b24.c16365"
            ]
        ]
    },
    {
        "id": "e8d550dc.bb719",
        "type": "www-request",
        "z": "3102625a.ead99e",
        "name": "GetSnapshot",
        "method": "GET",
        "ret": "bin",
        "url": "",
        "follow-redirects": true,
        "persistent-http": true,
        "tls": "",
        "x": 650,
        "y": 340,
        "wires": [
            [
                "d201d8cd.7f2468",
                "2a1bf02.0d4561"
            ]
        ]
    },
    {
        "id": "e489a75e.10c308",
        "type": "debug",
        "z": "3102625a.ead99e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "url",
        "targetType": "msg",
        "x": 860,
        "y": 480,
        "wires": []
    },
    {
        "id": "182d1b24.c16365",
        "type": "debug",
        "z": "3102625a.ead99e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 690,
        "y": 220,
        "wires": []
    },
    {
        "id": "2a1bf02.0d4561",
        "type": "debug",
        "z": "3102625a.ead99e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 870,
        "y": 420,
        "wires": []
    }
]

===========================
又折腾了一上午,还是不行,{“error”:{“code”:401},“success”:false}

大佬更新一下json吧。

同你一样 api有问题吧。

大佬好,流基本可以用了,请问一个问题:

Surveillance Station抓的图片存在哪里了?大概是什么文件夹,什么位置。