Running ffmpeg in exec node not working

I'm trying to take snapshots of my camera's rtsp stream. Stream is working on PC which is on the same LAN network as RPi400 with home assistant and node red.
There I'm unable to get it working.

In node I use this code:

ffmpeg -i "rtsp://user:password@cameraIP:554/stream1" -vframes 1 -qscale:v2 -y

When I run it, the message under node is changed to "pid:631" -> error:1
When I debug that node, I get this message -

msg.payload : string[0]
""

I tried to change the code so it doesn't contain " " but same problem.
What am I missing?

Thank you

Did you put that entire command string in the ‘Command” option of the exec node?

If so that won’t work. The command ‘ffmpeg’ should go there and all the rest of should go in the ‘extra input parameters’ option

Thank you for your response.
Unfortunately, I have just tried it and it's still the same - error 1.

Could there be a problem in node red configuration?
I have put there this

system_packages:

  • ffmpeg

What happens if you try that command in a terminal?

I get this error "at least one output file must be specified"

So I tried to edit command to

ffmpeg -i "rtsp://user:pass@192.168.15.121:554/stream1" -frames:v 1 -y -f image2 - frame_%d.png
This is generating file for each frame coming from the camera feed. However, I wanted just 1 frame.
So I edited the command to
ffmpeg -i "rtsp://user:pass@192.168.15.121:554/stream1" -frames:v 1 -y -f image2 - frame.png
Generating 1 file "frame.png" but gets error message - Could not get frame filename number 2 from pattern 'frame.png'. Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %03d within the filename.

When I try to use any of the commands above in node red exec node, it says pid:xxx and then gives me error:1

So I reckon there must be 2 problems.
1, My command is not exactly as it should be.
2, Even with bad command, exec node isn't generating file as my windows machine does.

Connect debug nodes set to Output Complete Message to outputs 2 and three of the Exec node and see what they show.

I don't think that is correct. If Append msg.payload is not set then the full command string can be specified in the Exec node. The node does not know the difference between different bits of the command, it just sends the complete string (with payload appended if specified) to the system.

@colin, your right...hmmm, I was under the impression that the command parameters needed to be in the 'options'. I ran into something like this a long time ago. I wonder if it changed at some point Iand I missed it (verry likely that I missed it.)

@Metafieldor there is a beta ffmpeg node you might want to look at. see Node-red-contrib-ffmpeg-spawn

I believe the purpose of the extra input parameters field is so that the command and parameters can be built up from three parts. First from the Command Field then (if enabled) the payload is concatenated, and then the extra parameters field on the end. If not using the payload then it can all just go in the Command field.

1 Like

Yeah! A wise man (who’s user name starts with ‘dcee…’) once told me, build the entire command in the node before the exec node, leave the command empty and check off the append msg.payload.

Solved. The problem was a bad command structure.
The one I use now is this:
ffmpeg -i "rtsp://user:pass@192.168.15.121:554/stream1" -frames:v 1 -y -f image2 "/config/Test/frame_$(date '+%s').jpg"

1 Like

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