Display camera ip in dashboard and store video in raspberry

Do we have a simple sample flow to try this out? With a public rtsp camera. Would be cool to see how this works out. Unfortunately I have no rtsp ip camera but I think there are some public ones out there. I have some url's to try with

Best regards, Walter

I'm currently following this instruction for one of my RPi3B, not finished yet but I believe you have to build from source like it's described in this guide

Hi Walter,

[{"id":"8c6b37c4.a5aef8","type":"inject","z":"fe2c7bc6.bd49c8","name":"Start stream","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"str","x":100,"y":4850,"wires":[["dc8a0ca9.117e9"]]},{"id":"2de27e17.be3c12","type":"inject","z":"fe2c7bc6.bd49c8","name":"Stop all streams","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"str","x":110,"y":4890,"wires":[["dc8a0ca9.117e9"]]},{"id":"40f893c3.a21d1c","type":"image-info","z":"fe2c7bc6.bd49c8","name":"","x":480,"y":4940,"wires":[["21cccabd.e70df6"]]},{"id":"15f19ef2.c099d1","type":"base64","z":"fe2c7bc6.bd49c8","name":"b64","action":"str","property":"payload","x":690,"y":4720,"wires":[["8b9cf7bd.a00318"]]},{"id":"8b9cf7bd.a00318","type":"ui_template","z":"fe2c7bc6.bd49c8","group":"51c96dc0.e62d64","name":"dash oeuf","order":1,"width":6,"height":4,"format":"<img width=\"16\" height=\"360\" src=\"data:image/jpg;base64,{{msg.payload}}\"/>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":830,"y":4720,"wires":[[]]},{"id":"361bb3b.15d904c","type":"ui_switch","z":"fe2c7bc6.bd49c8","name":"on/off stream","label":"","tooltip":"","group":"51c96dc0.e62d64","order":4,"width":1,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":100,"y":4870,"wires":[["dc8a0ca9.117e9"]]},{"id":"dc8a0ca9.117e9","type":"switch","z":"fe2c7bc6.bd49c8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":4830,"wires":[["2ca9755e.222aaa"],["a3c294f8.aed6b8"]]},{"id":"a3c294f8.aed6b8","type":"function","z":"fe2c7bc6.bd49c8","name":"stop","func":"msg= [\n    {\n    kill:'SIGTERM',\n    payload : 'SIGTERM'\n    }\n    \n    \n    ];     // set a new payload & the counter\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":4870,"wires":[["2ca9755e.222aaa"]]},{"id":"21cccabd.e70df6","type":"msg-speed","z":"fe2c7bc6.bd49c8","name":"","frequency":"sec","estimation":true,"ignore":false,"x":580,"y":4890,"wires":[["794946e8.e0b618","2cbb32f3.899c1e"],[]]},{"id":"2ca9755e.222aaa","type":"exec","z":"fe2c7bc6.bd49c8","command":"ffmpeg -rtsp_transport tcp -i  \"rtsp://192.168.1.7:554/user=xxxxx_password=xxxx_channel=0_stream=0.sdp?real_stream\" -filter:v fps=fps=5 -f image2pipe pipe:1","addpay":false,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"Decode RTSP stream","x":450,"y":4820,"wires":[["6ec96030.22aa"],["67ffbec1.566cf"],[]],"info":"oeuf:   MARCHE PAS \nffmpeg -rtsp_transport tcp -i  \"rtsp://admin:271273@192.168.1.6:554/onvif1\" -f image2pipe pipe:1\n\nmisecu : MARCHE OK\nffmpeg -rtsp_transport tcp -i  \"rtsp://192.168.1.7:554/user=admin_password=271273_channel=0_stream=1.sdp?real_stream\" -filter:v fps=fps=5 -f image2pipe pipe:1\n\nMARCHE OK avec le noeud pipe2jpeg :\n-----------------------------------\nameliorations : \n- fps=fps=5,scale=iw/2:-1     passe du 1080p à 960p = bon compromis qualité / charge cpu (45% => 25%)\nffmpeg -rtsp_transport tcp -i  \"rtsp://192.168.1.7:554/user=admin_password=271273_channel=0_stream=0.sdp?real_stream\" -filter:v fps=fps=5,scale=iw/2:-1 -f image2pipe pipe:1\n\n- MARCHE PAS !!! ffmpeg -hwaccels            c'est pour connaitre les capacité de la machine !!\n\n\n\n\nORIGINAL -> MP4:\n------------------\nffmpeg -loglevel quiet -progress pipe:1 -hwaccel auto -probesize 32 -analyzeduration 0 -reorder_queue_size 0 -rtsp_transport tcp -i rtsp://192.168.1.5:554/user=admin_password=pass_channel=1_stream=0.sdp -an -c:v copy -f mp4 -movflags +dash+negative_cts_offsets -metadata title=\"ip 192.168.1.4\" pipe:3 -c mjpeg -q 10 -r 7 -vf scale=trunc(iw*0.75/2)*2:-2 -f image2pipe pipe:4\n                ou\nffmpeg -loglevel info -progress pipe:3 -hwaccel auto -analyzeduration 10000000 -probesize 1048576 -re -f hls -i http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/hls/TearsOfSteel.m3u8 -c:a aac -c:v copy -f mp4 -movflags +dash+negative_cts_offsets pipe:1 -c mjpeg -q 10 -r 7 -vf scale=trunc(iw*0.75/2)*2:-2 -f image2pipe pipe:4\n\n\nmisecu -> MP4 : MARCHE PAS \nffmpeg -loglevel quiet -progress pipe:1 -hwaccel auto -probesize 32 -analyzeduration 0 -reorder_queue_size 0 -rtsp_transport tcp -i \"rtsp://192.168.1.7:554/user=admin_password=vEsQc8t4_channel=0_stream=1.sdp?real_stream\" -an -c:v copy -f mp4 -movflags +dash+negative_cts_offsets -metadata title=\"ip 192.168.1.4\" pipe:3 -c mjpeg -q 10 -r 7 -vf scale=trunc(iw*0.75/2)*2:-2 -f image2pipe pipe:4\n\n\nffmpeg -loglevel quiet -progress pipe:1 -hwaccel auto -probesize 32 -analyzeduration 0 -reorder_queue_size 0 -rtsp_transport tcp -i rtsp://192.168.1.7:554/user=admin_password=vEsQc8t4_channel=0_stream=1.sdp?real_stream -an -c:v copy -f mp4 -movflags +dash+negative_cts_offsets -metadata title=\"ip 192.168.1.4\" pipe:3 -c mjpeg -q 10 -r 7 -vf scale=trunc(iw*0.75/2)*2:-2 -f image2pipe pipe:4\n\nffmpeg -loglevel quiet -progress pipe:1 -hwaccel auto -probesize 32 -analyzeduration 0 -reorder_queue_size 0 -rtsp_transport tcp -i \"rtsp://192.168.1.7:554/user=admin_password=vEsQc8t4_channel=0_stream=1.sdp?real_stream\" -an -c:v copy -f mp4 -movflags +dash+negative_cts_offsets -metadata title=\"ip 192.168.1.54\" pipe:3 -c mjpeg -q 10 -r 7 -vf scale=trunc(iw*0.75/2)*2:-2 -f image2pipe pipe:4\n\n\nRTSP : j'ai enlevé -vf scale=trunc...   + remplace +dash+negative... par +frag_keyframe\n-------------------------------------------------------------------------------------------  MARCHE PAS !\nffmpeg -loglevel quiet -progress pipe:1 -hwaccel auto -probesize 32 -analyzeduration 0 -reorder_queue_size 0 -rtsp_transport tcp -i \"rtsp://192.168.1.7:554/user=admin_password=271273_channel=0_stream=1.sdp?real_stream\" -an -c:v copy -f mp4 -movflags +frag_keyframe -metadata title=\"ip 192.168.1.54\" pipe:3 -c mjpeg -q 10 -r 7 -f image2pipe pipe:4\n\n\n\n"},{"id":"794946e8.e0b618","type":"ui_valuetrail","z":"fe2c7bc6.bd49c8","group":"51c96dc0.e62d64","order":3,"width":3,"height":1,"name":"","label":"","blur":false,"minmax":false,"showvalue":false,"decimals":"0","colorLine":"#ff9900","colorFromTheme":true,"stroke":2,"property":"payload","pointcount":"24","x":800,"y":4880,"wires":[]},{"id":"2cbb32f3.899c1e","type":"ui_text","z":"fe2c7bc6.bd49c8","group":"51c96dc0.e62d64","order":5,"width":1,"height":1,"name":"fps","label":"{{msg.payload}}fps","format":"","layout":"row-center","x":790,"y":4920,"wires":[]},{"id":"67ffbec1.566cf","type":"debug","z":"fe2c7bc6.bd49c8","name":"complet","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":4830,"wires":[]},{"id":"66df6954.82e7b8","type":"image","z":"fe2c7bc6.bd49c8","name":"","width":"600","data":"payload","dataType":"msg","thumbnail":false,"active":false,"pass":false,"outputs":0,"x":540,"y":4650,"wires":[]},{"id":"6ec96030.22aa","type":"pipe2jpeg","z":"fe2c7bc6.bd49c8","name":"","x":510,"y":4720,"wires":[["40f893c3.a21d1c","15f19ef2.c099d1","66df6954.82e7b8"]]},{"id":"51c96dc0.e62d64","type":"ui_group","z":"","name":"camOeuf","tab":"250de740.57ee78","order":9,"disp":true,"width":"6","collapse":true},{"id":"250de740.57ee78","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
  • here is a flow of what I was able to make work with my IP cams in rtsp. Don't forget to install the npm install node-red-contrib-pipe2jpeg
  • In the EXEC node there is the rtsp address "rstp: // ...". Try with your public cam address.

Enjoy Chris

PS : I would look at your link to update FFMPEG as soon as I find 5 minutes free

Thanks a lot Chris, very kind!

I'm currently building the ffmpeg after compiling & installing the libraries according to step 1 to 8 , it will take a while and I will report back the result asap and hopefully it will be fine

Best regards, Walter

1 Like

Built ffmpeg finished. Here is the result. Good or bad, I don't know but the downloaded code (change log) indicates this is version 4.3
Changelog.txt (62.3 KB)

Your flow is working excellent with the pipe2jpeg node! With a public rtsp camera in Norway I tried and reached 10-11 fps with 1280x720. The cpu load in top indicates around 100% (25% of total) in the RPi3B and 40% of available memory is consumed by ffmpeg so running a bit too hot I think

EDIT: reduced to 5 fps and cpu load is 190-200% but memory consumption only 5.9 %. CPU temperature goes up to around 67 degrees. It then stopped but I do not know if it is because too high temperature or if it was because connection to camera was lost or broken after a while

pi@raspberrypi:~ $ ffmpeg -version
ffmpeg version git-2020-08-26-649a696 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs='-lpthread -lm -latomic' --arch=armel --enable-gmp --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-mmal --enable-nonfree --enable-omx --enable-omx-rpi --enable-version3 --target-os=linux --enable-pthreads --enable-openssl --enable-hardcoded-tables
libavutil      56. 58.100 / 56. 58.100
libavcodec     58.101.100 / 58.101.100
libavformat    58. 51.101 / 58. 51.101
libavdevice    58. 11.101 / 58. 11.101
libavfilter     7. 87.100 /  7. 87.100
libswscale      5.  8.100 /  5.  8.100
libswresample   3.  8.100 /  3.  8.100
libpostproc    55.  8.100 / 55.  8.100
pi@raspberrypi:~ $ ffmpeg -hide_banner -hwaccels
Hardware acceleration methods:
vdpau
vaapi
drm
pi@raspberrypi:~ $ ffmpeg -hide_banner -decoders|grep h264
 VFS..D h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 decoder wrapper (codec h264)
 V..... h264_mmal            h264 (mmal) (codec h264)

cool Walter, so we find the same decoder as @kevinGodell after update :slight_smile: the RPI3B is not buried !

Strange, you consume a lot ! :thinking:
With ffmpeg version 3.2.12 , when I stream my rtsp camera through the pipe2jpeg node at 1080p and 5 fps : my RPI3B takes 30% cpu ,8% RAM and 10°C more, compared to normal operation.
This is acceptable, and NR can do other tasks.

Is this what is shown in top?

yes , this is actually night 1080p vision 5fps : some peak to 37% cpu
image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.