Exec node error when running terminal commands

#1

i have error when using exec node to run commands . It works on the terminal. It streams video to youtube.
Can anyone help me how to run commands from nodered?

Thank you

0 Likes

#2

You have the append msg.payload option selected. This means the command it is running will have whatever msg.payload is to added at the end. This probably isn't what you want and could be causing the issue.

Have you got all three outputs wired to debug nodes so you can see any error messages it returns?

0 Likes

#3

I still have error. It works a while on the PC screen and disconnected before gng to youtube live stream.
Debug node msg,

Command failed: raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 6000000 -g 50 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/ ......

0 Likes

#4

Is it trying to preview the video also ? I think raspivid has an option to turn that off

-n. I think

0 Likes

#5

Try a different command to see if it is the command you are using. If it is the command you are using, try it in a terminal and see if it works...

0 Likes

#6

When you run it on the terminal make sure it does not display anything other than text in the terminal.

0 Likes

#7

I tried all the suggested still not working. It works on terminal bt not on nodered exec node. Is there any other alternatives?

0 Likes

#8

what are you actually trying to achieve?

0 Likes

#9

Are you running the command in the terminal in the same computer that is running node-red (not the one running the browser, if they are different).

If you are then simplify the command till it does not error, then add to it till you find what it is that fails.

Also check all outputs from the exec node to see if there is any additional information.

0 Likes

#10

raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 6000000 -g 50 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/3ssu-pv0e-510f-atr4
https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID

this is the command. i think it is stuck with error while trying to stream live to youtube. I separated the command rtmp://a.rtmp.youtube.com/live2/3ssu-pv0e-510f-atr4
https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID and put in extra input parameter. There was no error on the video bt it dosen't stream to youtube.

Cn i put the command in python code and run the file name from exec node? I m nt sure how to write python code. Can anyone help me on this?

0 Likes

#11

you still haven’t said what you are trying to achieve. What is the aim of the flow you are writing? You want to stream a video from youtube into Node-RED, once you have got it there what do you want to do with it?

0 Likes

#12

I m streaming video from camera to youtube. This is the tutorial i followed https://www.youtube.com/watch?v=pIV5HVeP9_o

0 Likes

#13

Did you try -n as I suggested ?

0 Likes

#14

yes didnt work either.

0 Likes

#15

Have you checked all the outputs from the exec node, it would be useful to be able to see the full error message.

Also please export the config of the exec node and paste it here so we can see exactly what you are trying, and can try it ourselves.

Colin

0 Likes

#16

Wrap the command in a bash script.

Run the script from the command line to confirm it works.

Try in the exec node

0 Likes

#17

Its working now thank you guys. I used bash script.

0 Likes

#18

How do i kill it. I did a fuction node msg.kill = true; it doesnt work.

[{"id":"a93dd8b3.041ad8","type":"debug","z":"6c0fc2e7.5fcb6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":720,"y":3740,"wires":[]},{"id":"a95cb02.0c7195","type":"exec","z":"6c0fc2e7.5fcb6c","command":"/home/pi/camyoutube.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":430,"y":3660,"wires":[["a93dd8b3.041ad8"],[],[]]},{"id":"568e7918.52ef68","type":"inject","z":"6c0fc2e7.5fcb6c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":3660,"wires":[["a95cb02.0c7195"]]},{"id":"53f1c37c.cb2abc","type":"function","z":"6c0fc2e7.5fcb6c","name":"","func":"msg.kill = true;\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":3840,"wires":[["a95cb02.0c7195"]]},{"id":"7cc4f0f6.0e30e","type":"inject","z":"6c0fc2e7.5fcb6c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":3780,"wires":[["53f1c37c.cb2abc"]]}]

0 Likes

#19

write a bash script to pkill your other script

0 Likes

#20

If this is a long running script you may want to look at the node-red-node-daemon node as that can pass msg s into stdin of the process and listens to stdout and stderr (But of course assumes your script can accept input while running)

For exec You can tell msg.kill what type of signal to use to stop the process so you should be able to find one that kills it properly.

0 Likes

Exec node cannot find any of my commands