# Pipeline with low latency problem

**URL:** <https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172>\
**Category:** Questions\
**Created:** [April 21, 2021, 2:16am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172 "2021-04-21T02:16:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 21, 2021, 2:16am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/1 "2021-04-21T02:16:57Z")

</div>

hello ~:

with blew configuration, I can not connected to my stream… , could u plz help me on it ?

- stream address

```auto
rtsp:// ***:*** @192.168.2.252:554/h264

```

- pipeline string:

```auto
rtspsrc location="{url}" latency=0 ! rtph264depay name="buffer_src" ! decodebin ! videoconvert ! vidleo/x-raw,format=(string)BGR ! appsink name="main_sink"

```

- server logs:

```auto
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:03 +0000] "GET /api/alerts?stream_id=6&limit=100&offset=0 HTTP/1.1" 200 2 "-" "python-urllib3/1.26.2"
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:03 +0000] "GET /api/zone_alarms?stream_id=6 HTTP/1.1" 200 2 "-" "python-urllib3/1.26.2"
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:03 +0000] "GET /api/zones?stream_id=6 HTTP/1.1" 200 66 "-" "python-urllib3/1.26.2"
core_1 | ERROR:bf_streaming.url(rtsp:// ***:*** @192.168.2.252:554/h264):Pipeline state is null. Restarting...
core_1 | WARNING:bf_streaming.url(rtsp:// ***:*** @192.168.2.252:554/h264):Error message on pipeline for rtsp:// ***:*** @192.168.2.252:554/h264: ../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline8/GstRTSPSrc:rtspsrc13/GstUDPSrc:udpsrc65:
core_1 | streaming stopped, reason not-linked (-1)
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:04 +0000] "GET /api/streams HTTP/1.1" 200 386 "-" "python-urllib3/1.26.2"
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:04 +0000] "GET /api/alerts?stream_id=6&limit=100&offset=0 HTTP/1.1" 200 2 "-" "python-urllib3/1.26.2"
http_proxy_1 | 192.168.3.15 - - [21/Apr/2021:02:12:04 +0000] "GET /api/zone_alarms?stream_id=6 HTTP/1.1" 200 2 "-" "python-urllib3/1.26.2"

```

---

<div class="post-metadata">

**Author:** ![tyler.compton](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/tyler.compton/32/27_2.png) [@tyler.compton](https://forum.aotu.ai/u/tyler.compton)\
**Post date:** [April 21, 2021, 4:51pm UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/2 "2021-04-21T16:51:38Z")

</div>

Hi delpanz, welcome to the forum!

I see that you’re using a custom pipeline to reduce latency. The pipeline looks fine, so perhaps the RTSP stream is outputting a format that BrainFrame doesn’t expect. Does this stream connect properly without a custom pipeline?

I think in order to diagnose the custom pipeline problem, we’ll need more logs. Please create a new file at `/usr/local/share/brainframe/.env` (assuming you used the BrainFrame CLI to install) with the following contents:

```auto
GST_DEBUG=3

```

Then, try creating the stream with your custom pipeline again and send me the new logs. Hopefully this will provide us with enough information to diagnose the problem.

---

<div class="post-metadata">

**Author:** ![tyler.compton](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/tyler.compton/32/27_2.png) [@tyler.compton](https://forum.aotu.ai/u/tyler.compton)\
**Post date:** [April 21, 2021, 5:17pm UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/3 "2021-04-21T17:17:18Z")

</div>

Actually, it looks like there’s a typo in your custom pipeline. The caps filter `vidleo/x-raw,format=(string)BGR` should instead be `video/x-raw,format=(string)BGR`. Here’s the full pipeline with the fix:

```auto
rtspsrc location="{url}" latency=0 ! rtph264depay name="buffer_src" ! decodebin ! videoconvert ! video/x-raw,format=(string)BGR ! appsink name="main_sink"

```

---

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 22, 2021, 1:45am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/4 "2021-04-22T01:45:27Z")

</div>

Thanks a lot , tyler:

it’s fixed by change rtph264depay to rtph265depay.  
but unfortunately, it’s seems not work, there’s still has a 5s latency…

---

<div class="post-metadata">

**Author:** ![alex.thiel](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/alex.thiel/32/48_2.png) [@alex.thiel](https://forum.aotu.ai/u/alex.thiel)\
**Post date:** [April 22, 2021, 5:31am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/5 "2021-04-22T05:31:11Z")

</div>

Could you send the logs with the `GST_DEBUG=3` change that Tyler recommended? Perhaps TCP is being used instead of UDP. Logs would be very helpful! 😃

---

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 22, 2021, 6:35am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/6 "2021-04-22T06:35:36Z")

</div>

Hello alex:

Here’s my log with GST\_DEBUG=3 and command "brainframe compose logs -f "  
plz help to check it… thanks a lot  
[bf\_logs.txt](https://forum.aotu.ai/uploads/short-url/6UiNIeTN4XC1zqhzjiU1MGIaknx.txt) (2.2 MB)

---

<div class="post-metadata">

**Author:** ![alex.thiel](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/alex.thiel/32/48_2.png) [@alex.thiel](https://forum.aotu.ai/u/alex.thiel)\
**Post date:** [April 22, 2021, 7:49pm UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/7 "2021-04-22T19:49:59Z")

</div>

Hmm, I wasn’t able to see anything in those logs.

Could you try adding the protocol to `rtspsrc`?

```auto
rtspsrc location="{url}" latency=0 protocol=udp

```

I think that should force UDP. I’m curious if this will improve latency for you.

---

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 24, 2021, 1:26am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/8 "2021-04-24T01:26:45Z")

</div>

seems not work…  
and i will reinstall the brainframe and test again

---

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 26, 2021, 9:23am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/9 "2021-04-26T09:23:29Z")

</div>

Hi Alex:  
The latency become lower after reduce the video source size from 4k to 720P.  
But still has a latency of 1s.

and here’s my pipeline:

```auto
rtspsrc location="{url}" latency=0 protocol=udp ! rtph265depay name="buffer_src" ! decodebin ! videoconvert ! video/x-raw,format=(string)BGR ! appsink name="main_sink"

```

So, I guess there’s maybe some **buffer** in brainframe server side. But I can not find any docs on this details.  
really appreciate if you can tell us more details …

Thank you.

---

<div class="post-metadata">

**Author:** ![alex.thiel](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/alex.thiel/32/48_2.png) [@alex.thiel](https://forum.aotu.ai/u/alex.thiel)\
**Post date:** [April 27, 2021, 4:39pm UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/10 "2021-04-27T16:39:36Z")

</div>

Can I ask what your application is?

BrainFrame (Server) doesn’t have any buffers, but the BrainFrame Client does. The Client has to buffer until it receives inference results from the server, so that it can pair up frames to their bounding boxes. The client does this even if there are no capsules loaded on the server.

---

<div class="post-metadata">

**Author:** ![delpanz](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@delpanz](https://forum.aotu.ai/u/delpanz)\
**Post date:** [April 28, 2021, 1:30am UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/11 "2021-04-28T01:30:03Z")

</div>

> [@alex.thiel](#):
>
> rver.

Hi Alex，  
Our app is just show the video from IP camera, and has a latency about 2s.  
Thanks for your sharing about the buffer details. It’s really helpful for us.

Thank you.

---

<div class="post-metadata">

**Author:** ![alex.thiel](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.aotu.ai/alex.thiel/32/48_2.png) [@alex.thiel](https://forum.aotu.ai/u/alex.thiel)\
**Post date:** [April 28, 2021, 6:43pm UTC](https://forum.aotu.ai/t/pipeline-with-low-latency-problem/172/12 "2021-04-28T18:43:07Z")

</div>

Got it, thank you for the info.

Did you know that the BrainFrame Client is actually Open Source? The source code [can be found here](https://github.com/aotuai/brainframe-qt). All of the logic for displaying video + bounding boxes can be found in that repository. It’s also easy to package and build a `snap` for it to distribute a modified version.

Feel free to ask any questions if this is something you are interested in.
