Display camera ip in dashboard and store video in raspberry

In januari I was completely stuck, so I contacted Kevin Godell. Got immediate help from Kevin, so would like to thank him for his time!!!!!! After some research, he came up with following ffmpeg command:

-f mjpeg -i pipe:0 -vf scale=320:240 -f image2pipe pipe:1

When you use this command in Node-RED's daemon node, it is now possible to pass images via memory (stdin stream pipe:0) to ffmpeg (since we (ab)use an mjpeg stream to be able to process an infinite series of images). And the resized image is returned back to Node-RED as an output message (stdout stream pipe:1):

[{"id":"122804f3.f8b7eb","type":"daemon","z":"50df184.124f2e8","name":"Resize image","command":"/home/pi/FFmpeg/ffmpeg","args":"-f mjpeg -i pipe:0 -vf scale=320:240 -f image2pipe pipe:1","autorun":true,"cr":false,"redo":true,"op":"buffer","closer":"SIGTERM","x":560,"y":320,"wires":[["98ce6e9f.81789"],[],[]]},{"id":"631c9e62.c5bf1","type":"inject","z":"50df184.124f2e8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":340,"wires":[["afda2c1f.ec754"]]},{"id":"dfde7d7e.a8b0b","type":"image","z":"50df184.124f2e8","name":"","width":200,"x":980,"y":300,"wires":[]},{"id":"afda2c1f.ec754","type":"http request","z":"50df184.124f2e8","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"https://static.independent.co.uk/s3fs-public/thumbnails/image/2017/09/12/11/naturo-monkey-selfie.jpg?w968","tls":"","proxy":"","authType":"basic","x":340,"y":340,"wires":[["122804f3.f8b7eb","c886e69d.47aa98"]]},{"id":"93ccc4c3.6f45c8","type":"image","z":"50df184.124f2e8","name":"","width":200,"x":720,"y":400,"wires":[]},{"id":"c886e69d.47aa98","type":"image-info","z":"50df184.124f2e8","name":"","x":530,"y":400,"wires":[["93ccc4c3.6f45c8"]]},{"id":"98ce6e9f.81789","type":"image-info","z":"50df184.124f2e8","name":"","x":790,"y":300,"wires":[["dfde7d7e.a8b0b"]]},{"id":"853bae8d.c380d","type":"comment","z":"50df184.124f2e8","name":"Image processing without spawn but with delay","info":"-f mjpeg -i pipe:0 -vf scale=320:240 -f image2pipe pipe:1","x":660,"y":260,"wires":[]}]

Advantages:

  • All data is passed via memory, and no temporary files (or disc IO) is needed.
  • A single daemon ffmpeg needs to be spawned that processes all images. I.e. it is not necessary to spawn a new ffmpeg process for every image, like e.g. the ffmpeg-stream package.

Disadvantage: there is a single image delay :woozy_face: When you insert an image nothing happens. As soon as you inject the second image, the first image will arrive on the output. And so on ... Not 100% sure what the problem is, but after the first image is inserted I get only this output (on stderr and adding -loglevel debug):

[mjpeg @ 0x7fffcd526700] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1

This is similar to the issue I had before: since we (ab)use an mjpeg stream, ffmeg wants to collect information about that stream. And I think that causes the delay. But I'm not sure...

Unless somebody else has some usefull tips, I will have to stop with this mechanism :weary: Would be a pitty, since we are almost there. And it would have been an awesome addition for Node-RED... P.S. I'm not referring to the image resizing, because that is only a simple test that you can also achieve with node-red-contrib-image-tools in pure Javascript ...