# Shmsink/src or udpsink/src

**URL:** https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907
**Category:** Application Development
**Created:** [July 9, 2024, 5:58am UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907 "2024-07-09T05:58:18Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![rottnest](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rottnest/32/136_2.png) [@rottnest](https://discourse.gstreamer.org/u/rottnest)
#### Post date: [July 9, 2024, 5:58am UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/1 "2024-07-09T05:58:18Z")

</div>

I’m struggling with latency.  
I want to share video from 1 user to another user.  
My pipeline with udp works but I hold CPU cores in 90s % usage and I get lag caused by that. Any opinion if shm would have lower usage.  
Thanks  
James

---

<div class="post-metadata">

### Author: ![Honey\_Patouceul](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/honey_patouceul/32/365_2.png) [@Honey\_Patouceul](https://discourse.gstreamer.org/u/Honey_Patouceul)
#### Post date: [July 10, 2024, 7:57pm UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/2 "2024-07-10T19:57:21Z")

</div>

Not sure, it depends on your actual platform and use case, but I don’t think that shmsrc/shmsink is the easiest way for your case.  
It also depends on what format you’re sending through, but time stamping may be an issue.  
In some cases you may try enabling shmsrc property `do-timestamp=1`.

Though, I’d better advise to use RTP over UDP for localhost. You can have a look to [this post](https://discourse.gstreamer.org/t/unable-to-stream-video-with-gstreamer-http-server/1179/6) for some options depending on actual formats/encoding/RTPpayload.

---

<div class="post-metadata">

### Author: ![rottnest](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rottnest/32/136_2.png) [@rottnest](https://discourse.gstreamer.org/u/rottnest)
#### Post date: [July 10, 2024, 10:46pm UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/3 "2024-07-10T22:46:22Z")

</div>

Thanks lots!  
Bizare! I’m using rtph264pay. If I stream as user1 and watch as user1 the latency is perfect.  
If I watch as user2 then the stream drifts back in time: some 5secs / minute

Nothing else changed. Has anyone any ideas?

 ![latency](https://discourse.gstreamer.org/uploads/default/original/1X/33f4afc8bd024f9f37928a130467542bddf55ea2.jpeg)

James

---

<div class="post-metadata">

### Author: ![Honey\_Patouceul](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/honey_patouceul/32/365_2.png) [@Honey\_Patouceul](https://discourse.gstreamer.org/u/Honey_Patouceul)
#### Post date: [July 11, 2024, 7:28pm UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/4 "2024-07-11T19:28:23Z")

</div>

Can you try without NoMachine in the loop ?

---

<div class="post-metadata">

### Author: ![rottnest](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rottnest/32/136_2.png) [@rottnest](https://discourse.gstreamer.org/u/rottnest)
#### Post date: [July 12, 2024, 12:03am UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/5 "2024-07-12T00:03:15Z")

</div>

Ta, I’ll ponder how to do that - 1 machine - 1 display and keyboard: User1 acquires video, User2 watches stream.  
I’ll try nomachine launches then shuts down, User2 watches  
I’ll give the exact scenario in case there are ideas, better than this:  
Divemaster collects video from 1 to 4 divers. He watches and talks to all divers.  
In other parts of ship watchers watch, fullscreen, a particular diver.  
I tried HTML streaming with tcp. Works except that the watchers are likely to usevwingows laptops and windows-explore will not accept the bug in tcpserversrc, only firefox will.

Pictures show a diver, Divemaster and watchers screens

 ![d1](https://discourse.gstreamer.org/uploads/default/original/1X/be62d78b53a179d3dee84364d60a7308443c9a5a.jpeg)

 ![d2](https://discourse.gstreamer.org/uploads/default/original/1X/6bda885ce78dd90bb461e3571eb3ff8720c61faf.jpeg)

The watcher screen drifts 5 secs per minute on udpsink/src as another user

---

<div class="post-metadata">

### Author: ![rottnest](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rottnest/32/136_2.png) [@rottnest](https://discourse.gstreamer.org/u/rottnest)
#### Post date: [July 13, 2024, 9:08am UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/6 "2024-07-13T09:08:48Z")

</div>

I’m utterley confused, there must be something I do not understand

User1 publishes a udp stream

If I watch that stream as User1 it is perfectly syncronised. If I watch as User2 it drifts back in time oooooh 5 secs / min.

I watch with this script:  
#!/bin/sh  
if [$# -lt 1];then  
echo usage diver number  
exit  
fi  
CHAN=$1  
APORT=$((3444+$CHAN))  
VPORT=$((5000+$CHAN))

echo “aport:” $APORT " vport:" $VPORT

gst-launch-1.0 -vc \   
udpsrc port=$VPORT close-socket=false multicast-iface=false auto-multicast=true ! application/x-rtp, payload=96 ! \   
rtpjitterbuffer ! \   
rtph264depay !   
avdec\_h264 !   
xvimagesink sync=false async=false   
udpsrc port=$APORT !   
‘application/x-rtp,media=audio,payload=96,clock-rate=22000,encoding-name=L24’ !   
rtpL24depay !   
audioconvert !   
autoaudiosink sync=false

If anyone has inspiration or ideas, I’d be so gratefull. The picture is after 1/2 hour of streaming (not clear time 16:43:08)

 ![doug](https://discourse.gstreamer.org/uploads/default/original/1X/f82766ad8884bcb8ed97446a57137f51c435c48b.jpeg)

---

<div class="post-metadata">

### Author: ![tpm](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/t/c5a1d2/32.png) [@tpm](https://discourse.gstreamer.org/u/tpm)
#### Post date: [July 14, 2024, 6:17pm UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/7 "2024-07-14T18:17:13Z")

</div>

Just to simplify the setup a little, are you seeing the same issue if you remove the audio branch and do video only?

Note that with `sync=false` you’ll probably get jittery video.

---

<div class="post-metadata">

### Author: ![rottnest](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/rottnest/32/136_2.png) [@rottnest](https://discourse.gstreamer.org/u/rottnest)
#### Post date: [July 17, 2024, 10:21am UTC](https://discourse.gstreamer.org/t/shmsink-src-or-udpsink-src/1907/8 "2024-07-17T10:21:57Z")

</div>

Page … Page … Page … Here it is on page 1

Watching the stream as User1 sent by User1 cpu cores at 75ish% and latency is well sub 1 sec

Watching the stream as User2 sent by User1, 2 cores and 2 threads late 90s% and latency some 5 secs per min.

Relieved to have found it. Dissapointed!

James
