# Error code in RTSP stream decoding

**URL:** <https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192>\
**Category:** General\
**Created:** [3 April 2023 10:38 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192 "2023-04-03T10:38:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [3 April 2023 10:38 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/1 "2023-04-03T10:38:41Z")

</div>

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/5236bb358b82e70817cb7a6bef7d97d4fff65e99.png)  
This is the code I use to decode my rtsp stream from an Sonoff camera (GK-200MP2-B):  
ffmpeg -f rtsp -i "rtsp://rtsp:xxxxxx@192.168.178.73:554/av\_stream/ch0" -f image2pipe pipe:1  
xxxx = the code I received from the camera.  
As you can see I receive rc:-2 instead of the image preview when clicking the Start Stream inject node.  
I know the rtsp stream is good, because I receive in a picture card in Home Assistant the stream (movie).  
But maybe I have to delete or change a part of the code.  
I hope somebody is able to help me to explain what I do wrong.  
Thank you.  
Yvonne

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 April 2023 14:20 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/2 "2023-04-03T14:20:30Z")

</div>

Set the debug nodes to output the full message and inspect each one carefully, you should find an error message in there somewhere.

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [3 April 2023 16:35 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/3 "2023-04-03T16:35:31Z")

</div>

Thank you Collin. The message is:  
payload: object  
code: -2  
topic: ""  
So it seems to me it has to do with the empty topic.  
But I can't understand where I need a topic for.  
I don't use a topic.  
So it's a mystery for me.  
I don't know if you have a solution, but thanks for your help.

Yvonne

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 April 2023 17:06 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/4 "2023-04-03T17:06:51Z")

</div>

I meant all three debug nodes

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 April 2023 17:07 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/5 "2023-04-03T17:07:33Z")

</div>

And what is in the object in the payload?

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [3 April 2023 17:35 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/6 "2023-04-03T17:35:27Z")

</div>

Payload:object  
Topic:””

Start stream:

![Naamloos 4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d2d2053b3aa0c4484bb4190d8ec01486114728c.jpeg)

Exec node: Decode RTSP stream:

![Naamloos](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4ce83ae46e504bea849cc98b8963f469ae7ae900.jpeg)

Image node:  
 ![Naamloos 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/96f680545d56a77a15ee69f2a370ec1c1be75e43.jpeg)

Image preview:

![Naamloos 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a07863e9e35be69e4dddcb8faf736145de0a820.jpeg)

The error code is with the lowest msg

 ![Naamloos 5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd3fbc8659b8b20fad8f64a79fe3e3128ea830b0.jpeg)

All the debug nodes are the same, only the last has an error: -2  
 ![Naamloos 6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f893fbe96513b98706e7cfbfa4a5e6ed50525bb.jpeg)

Thank you Colin

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 April 2023 18:55 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/7 "2023-04-03T18:55:24Z")

</div>

Export the exec node and paste it here.

First try providing the full path to ffmpeg

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [4 April 2023 13:55 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/8 "2023-04-04T13:55:08Z")

</div>

[flows.json](https://discourse.nodered.org/uploads/short-url/zNaI50FvOWPxliOHF4qtUiVeU4W.json) (386 Bytes)

Hi Colin,

I uploaded the exec node.  
I think that it contains the whole path.

Thank you.  
Yvonne

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [4 April 2023 14:11 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/9 "2023-04-04T14:11:45Z")

</div>

Try instead to use the nice working nodes developed & shared by @kevinGodell

> [@Node-red-contrib-ffmpeg-spawn](https://discourse.nodered.org/t/node-red-contrib-ffmpeg-spawn/44427):
>
> The ffmpeg node is ready for testing. It is similar to the exec node to spawn ffmpeg, with additional features. An example flow doing way more than a regular human needs to do: [{"id":"93d74c4e.4c8fe","type":"ffmpeg-spawn","z":"5967c855.68b978","name":"","outputs":5,"migrate":1e-9,"cmdPath":"ffmpeg","cmdArgs":"[\"-loglevel\",\"error\",\"-nostats\",\"-f\",\"hls\",\"-http\_multiple\",\"1\",\"-re\",\"-i\",\"https://weather-lh.akamaihd.net/i/twc\_1@92006/index\_1200\_av-p.m3u8?sd=10&rebase=on\",\"-c:v…

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [4 April 2023 14:39 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/10 "2023-04-04T14:39:21Z")

</div>

Thanks Kevin.  
I will read it and try it if I don't succeed with the old flow.  
I'm happy with the support.  
Yvonne

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [4 April 2023 14:40 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/11 "2023-04-04T14:40:43Z")

</div>

I'm not Kevin, I'm Walter, just a happy user of Kevin's great work!

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [4 April 2023 14:51 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/12 "2023-04-04T14:51:49Z")

</div>

Sorry for that!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [4 April 2023 14:56 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/13 "2023-04-04T14:56:47Z")

</div>

No problem 😉

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 April 2023 19:58 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/14 "2023-04-04T19:58:37Z")

</div>

For the future see this post for how to post flows or code - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

What OS and hardware are you running on, and how did you install node-red?

What does this command show, running in a command window?  
`which ffmpeg`

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [5 April 2023 09:46 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/15 "2023-04-05T09:46:37Z")

</div>

Thank you Colin. I will read this article about posting flows or code.  
I have no clue where I can find the versionof ffmpeg. I installed Home Assistant OS without desktop.  
The command which ffmpeg doesn't work in the terminal.  
I installed everything last week, so I assume that I will have the latest version installed.  
In a picture card I can see the video of the Sonoff camera, so ffmpeg must be working properly. In the configuration.yaml file I have these lines of code:  
camera:

- platform: ffmpeg  
name: Sonoff cam  
input: -rtsp\_transport tcp -i rtsp://rtsp:xxxxx@192.168.xxx.xx:554/av\_stream/ch0

If you get tired of me, please me know.  
Thank you.

Yvonne

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 April 2023 10:08 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/16 "2023-04-05T10:08:55Z")

</div>

> [@lodv](#):
>
> I installed Home Assistant OS

That is very important. Assuming that you installed the node-red plugin for HA then that means that node-red is running inside a Docker container and so does not have access to s/w such as ffmpeg installed into the host operating system. I think that you would have to install ffmpeg into the container running node-red. I have no idea how you would do that in HA, you would have to ask on an HA forum I think.

Very few here use HA, preferring to do everything directly in node-red.

> [@lodv](#):
>
> The command which ffmpeg doesn't work in the terminal.

That suggests that you have not even installed ffmpeg in the operating system. Does the command you have put in the exec node work if you run it in a terminal? If not then it obviously won't work in node-red.

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [5 April 2023 10:27 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/17 "2023-04-05T10:27:46Z")

</div>

No.  
bash: ffmpeg: command not found.  
I think that you are right with the container.  
I was not aware that the add-on in Home Assistant would run in a Docker container.  
But, I think that this answer of you will put me in the right direction.  
Although I still don't understand why I can run ffmeg in the picture card with  
camera:

- platform: ffmpeg  
name: Sonoff cam  
input: -rtsp\_transport tcp -i rtsp://rtsp:5Nk8NL8M@192.168.xxx.xx:554/av\_stream/ch0

while this is a ffmpeg stream as well.

I will look further Colin.  
Thank you for your patience and help.

Yvonne

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 April 2023 10:38 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/18 "2023-04-05T10:38:57Z")

</div>

> [@lodv](#):
>
> I still don't understand why I can run ffmeg in the picture card with  
> camera:

Perhaps that is running in a different container that does have ffmpeg installed.

---

<div class="post-metadata">

**Author:** ![lodv](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lodv/32/7963_2.png) [@lodv](https://discourse.nodered.org/u/lodv)\
**Post date:** [5 April 2023 10:52 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/19 "2023-04-05T10:52:43Z")

</div>

Oke. I will close the topic and work further.  
Colin, thank you very much.  
It was really helpful.

Yvonne

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 June 2023 10:53 UTC](https://discourse.nodered.org/t/error-code-in-rtsp-stream-decoding/77192/20 "2023-06-04T10:53:38Z")

</div>

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