Node-Red v3.1.0 Exec node now causing an Error

The following command works without issue in the Terminal of the Raspberry PI

ffmpeg -i /path/to/your/audiofile.mp3 -f wav - | aplay

and use to work in the Node Red exec node, but now fails producing an unknown error.
image

aplay: main:830: audio open error: Unknown error 524

What has changed in Node Red Exec?

  1. What version of NR did it work on?
  2. add a catch node connected to a debug node (set to display the complete msg object) and see if it shows anything
  3. take a look at the node-red log and see if it shows anything.
  4. have you done any other upgrades (like the os)?
  • It worked on recent NR prior to the release of 3.1.

  • Catch Node does not show anything in the Debug msg.object

  • Exec Node stderr shows as aplay: main:830: audio open error: Unknown error 524 as already mentioned.

  • The Node Red Console on the RPI doesn't show any errors.

  • Yes I have recently upgraded the OS to Bullseye, and at the same time as going to NR 3.1.

Nevertheless the command works in the Terminal on the RPI but not when in the NR Exec node on the same device.

image

Incidentally the filename use to have to be in quotes in exec node but in the Terminal, at least currently, the quotes are not essential. But doesn't work with or without quoptes in NR Exec node now.

Many things that work fine in terminal (espeically sound things) don't translate direct to exec node :frowning:

I'm sure it's not the issue but why is there a - just before the pipe | ?

There has to be at least one output file, so the - is required before the pipe......at least that is my interpretation if I remove the '-'.

Asssuming you jsut want to hear an .mp3 file playing - see if mpg123 works for you

I used to have some flows that played .mp3 from a Pi but of course I can't find any of them now! :frowning:

[edit] found an old exec with aplay in it that had few parameters to direct the sound to the headphone socket on the pi - don't know if this will help you?

image

Thanks, the purpose is to play any sound to a Bluetooth Speaker.

I used it in conjunction with Google Text To Speech to output audio feedback to an Alexa Amazon Dot from NR flows.

I may try winding back on the NR versions to see when the issues appeared. Just seems strange that it used to work fine and now doesn't but the command still works in the Terminal.

Its unlikely to be an NR version issue as NR just executes what you tell it to

I'm no linux expert but Rasperry Pi were always playing around with sound things from OS to OS. - maybe they still are

And the exec node doesn't work exactly the same as a standard terminal

I've just tried out mpg123 and it works in NR 3.1.0 Bullseye (at least it outputs to the 3.5mm audio socket)

How did you install node red on the pi?

When you run it in a terminal are you logged in as the same user that runs node red?

  • I installed NR using the bash script on the web site.

  • Yes logged in as same user on the pi and for NR on the RPI Zero 2W

I've now wound back through the releases to version 1.1.3 and the error is still being produced, so beginning to look as though as not due NR per se. Haven't gone back to earlier Node.js releases yet.

I think it is more likely to be an OS change that has made the difference.

1 Like

Also try sending the ffmpeg output direct to a file and see if that works.

The original Flow dates back to early 2020, unfortunately appending the appropriate Node version to the NR installation results in a failed Node.js install, so my I seem to have been thwarted in investigating that route for the anomalous behaviour. As you say it seems most likely due to an OS or maybe Node.js change. Sending the ffmpeg output from the Exec Node direct to file only results in an error report etc. as seen below.
Command failed: ffmpeg -i "/home/pi/Desktop/audio.mp3" -f wav - | aplayaplay: main:830: audio open error: Unknown error 524ffmpeg version 4.3.6-0+deb11u1+rpt5 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 10 (Raspbian 10.2.1-6+rpi1) configuration: --prefix=/usr --extra-version=0+deb11u1+rpt5 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-li...

Further investigation would suggest that for whatever reason the Exec Node can no longer execute the aplay command.

Saving the ffmpeg output direct to a file in the Exec node rather than piping it to aplay and then trying to play that file in an Exec node using aplay fails with

Command failed: aplay /home/pi/Desktop/out.wavaplay: main:830: audio open error: Unknown error 524

Such a shame! :face_exhaling: :face_exhaling: :frowning_face:

Does that a aplay command work in a terminal?

Yes the aplay works in a terminal.

Yes the aplay command works in a terminal to play that saved file.

Please start node red using
node-red-stop
node-red-start
Keep the command window open and tell node red to play the file. Then copy/paste here the full output, from the welcome to node red message, to the error and anything immediately after the error. Copy/paste please, not screen shot.

As I said earlier, the Node Red console shows no changes on executing the exec Node command

pi@piZero2:~ $ node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.1.8:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
16 Sep 16:41:38 - [info]
Welcome to Node-RED
===================
16 Sep 16:41:38 - [info] Node-RED version: v3.1.0
16 Sep 16:41:38 - [info] Node.js  version: v18.17.1
16 Sep 16:41:38 - [info] Linux 6.1.21-v7+ arm LE
16 Sep 16:41:41 - [info] Loading palette nodes
level info
16 Sep 16:41:53 - [info] Settings file  : /home/pi/.node-red/settings.js
16 Sep 16:41:53 - [info] Context store  : 'default' [module=memory]
16 Sep 16:41:53 - [info] User directory : /home/pi/.node-red
16 Sep 16:41:53 - [warn] Projects disabled : editorTheme.projects.enabled=false
16 Sep 16:41:53 - [info] Flows file     : /home/pi/.node-red/flows.json
16 Sep 16:41:53 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
16 Sep 16:41:53 - [info] Server now running at http://127.0.0.1:1880/
16 Sep 16:41:53 - [info] Starting flows
Platform node has already been set. Overwriting the platform with node.
16 Sep 16:41:57 - [error] [tensorflowCoco:6f95ae40e7e2711e] Error: /home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v8/tfjs_binding.node: wrong ELF class: ELFCLASS64
16 Sep 16:41:58 - [info] Started flows
16 Sep 16:41:58 - [info] [mqtt-broker:ea104de9504b9a94] Connected to broker: mqtt://192.168.1.8:1883

Thought I might be able to get round it by executing a bash script from Node Red Exec, but even that fails.

In the Terminal

pi@piZero2:~ $ bash /home/pi/Desktop/play_audio.sh
Playing WAVE '/home/pi/Desktop/out.wav' : Signed 16 bit Little Endian, Rate 24000 Hz, Mono
pi@piZero2:~ $ 

and in Node Red
image
image
image

Has aplay got any command line options to give more verbose output?