node-red html5流媒体视频

时间:2017-10-02 17:12:42

标签: video-streaming node-red

我是node-red和javascript的新手,我希望有人可以帮助我。我一直在尝试使用node-red来传输视频。我已经使用此流程成功显示了图像。

[{
    "id": "c2701738.8bfcb",
    "type": "http response",
    "z": "6a1a7f76.b846d8",
    "name": "",
    "statusCode": "",
    "headers": {},
    "x": 1118.170166015625,
    "y": 3207,
    "wires": []
  },

  {
    "id": "4d34db55.ad8834",
    "type": "function",
    "z": "6a1a7f76.b846d8",
    "name": "Set Content-Type header",
    "func": "msg.headers = { \"Content-Type\":\"image/png\"};\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "x": 882.170166015625,
    "y": 3207,
    "wires": [
      ["c2701738.8bfcb"]
    ]
  }, {
    "id": "21504cc0.71adcc",
    "type": "http in",
    "z": "6a1a7f76.b846d8",
    "name": "",
    "url": "/image1",
    "method": "get",
    "upload": false,
    "swaggerDoc": "",
    "x": 145.17022705078125,
    "y": 3206,
    "wires": [
      ["aa24fb51.7861f"]
    ]
  }, {
    "id": "aa24fb51.7861f",
    "type": "file in",
    "z": "6a1a7f76.b846d8",
    "name": "Picture Selector",
    "filename": "/home/pi/.node-red/lee.png",
    "format": "",
    "sendError": true,
    "x": 596.1702270507812,
    "y": 3207.000244140625,
    "wires": [
      ["4d34db55.ad8834"]
    ]
  }
]

我尝试了这个流来播放视频。

[{
  "id": "47af46de.9382d8",
  "type": "http in",
  "z": "6a1a7f76.b846d8",
  "name": "",
  "url": "/video3",
  "method": "get",
  "upload": false,
  "swaggerDoc": "",
  "x": 139,
  "y": 3369,
  "wires": [
    ["9da4e018.797ce8"]
  ]
}, {
  "id": "f7318675.c876a",
  "type": "function",
  "z": "6a1a7f76.b846d8",
  "name": "Set Content-Type header",
  "func": "msg.headers = { \"Content-Type\":\"video/mp4\"};\nreturn msg;",
  "outputs": 1,
  "noerr": 0,
  "x": 869.9999389648438,
  "y": 3370,
  "wires": [
    ["2e33de98.3a55da"]
  ]
}, {
  "id": "2e33de98.3a55da",
  "type": "http response",
  "z": "6a1a7f76.b846d8",
  "name": "",
  "statusCode": "",
  "headers": {},
  "x": 1110.9999389648438,
  "y": 3371,
  "wires": []
}, {
  "id": "9da4e018.797ce8",
  "type": "file in",
  "z": "6a1a7f76.b846d8",
  "name": "Video Selector",
  "filename": "/home/pi/.node-red/1.mp4",
  "format": "stream",
  "sendError": false,
  "x": 592,
  "y": 3369.000244140625,
  "wires": [
    ["f7318675.c876a"]
  ]
}]

也是这个。

[{
  "id": "28aa7076.b2c0e",
  "type": "http in",
  "z": "6a1a7f76.b846d8",
  "name": "",
  "url": "/video4",
  "method": "get",
  "upload": false,
  "swaggerDoc": "",
  "x": 145,
  "y": 3525,
  "wires": [
    ["898878ed.61ff48"]
  ]
}, {
  "id": "866daf6f.5eb068",
  "type": "http response",
  "z": "6a1a7f76.b846d8",
  "name": "",
  "statusCode": "",
  "headers": {},
  "x": 874.5,
  "y": 3528,
  "wires": []
}, {
  "id": "a1babcbf.9ecac8",
  "type": "template",
  "z": "6a1a7f76.b846d8",
  "name": "",
  "field": "payload",
  "fieldType": "msg",
  "format": "handlebars",
  "syntax": "mustache",
  "template": "<!DOCTYPE html>\n<html>\n<body>\n\n<video width=\"640\" height=\"480\" autoplay>\n  <source src=\"{{msg.payload}}\" type=\"video/mp4\">\n  Your browser does not support the video tag.\n</video>\n\n</body>\n</html>\n\n",
  "output": "str",
  "x": 732,
  "y": 3528,
  "wires": [
    ["866daf6f.5eb068"]
  ]
}, {
  "id": "898878ed.61ff48",
  "type": "file in",
  "z": "6a1a7f76.b846d8",
  "name": "videoSelector",
  "filename": "/home/pi/.node-red/1.mp4",
  "format": "stream",
  "sendError": true,
  "x": 483,
  "y": 3528,
  "wires": [
    ["a1babcbf.9ecac8"]
  ]
}]

两个视频流都会抛出“无响应对象”消息。

提前感谢您的帮助。

麦克

1 个答案:

答案 0 :(得分:0)

您不能将流模式与http-inhttp-response节点一起使用,因为在此模式下,file-in节点会为文件的每个块创建新消息。

尝试buffer模式。