OBS-Studio: Send an UDP Stream to a second PC using OBS

OBS Studio OBS-Studio: Send an UDP Stream to a second PC using OBS

Jack0r

The Helping Squad
Forum Moderator
#1
Jack0r submitted a new resource:

OBS-Studio: Send an UDP Stream to a second PC using OBS - The custom ffmpeg output allows us to use different output protocols, here is one example.

First we of course have to configure OBS-Studio:

  • Settings -> Output -> Mode -> Advanced
    • Recording Tab -> Type -> Custom Output (FFmpeg)
    • FFmpeg Output Type -> Output to URL
    • File path or URL -> udp / rtp / rtsp / tcp ://receiver.ip.address:port
      (f.e. udp://192.168.0.5:1234)
    • Container Format -> Depends on the protocol, for udp it would be mpegts for example, make sure to select a streamable...
Read more about this resource...
 

dnb

New Member
#5
2 reasons I can think of:
1 - RTMP has some overhead being a protocol which is a superset of UDP. IE, it has more stuff in the UDP datagram packets so you get less frames of video/audio per burst. As such, frame losses due to dropped UDP packets via RTMP are more drastic and will cause higher corruption of the stream.
2 - You don't need a server to broadcast UDP. The tutorial SHOULD have walked you through a process of setting up an output to a UDP multicast IP (i.e., udp://224.0.0.1:9999). This special subnet is capable of being sent and received on a local network. For RTMP, you need something to wrap the UDP packets with the RTMP protocol for proper slicing due to how RTMP allows seeking of previous uncached data.

Feel free to ask more questions, but I might be slow-replying.


EDIT:

I just actually read thoroughly, and he's technically doing it wrong by pointing to his own IP (or really any Class-C subnet). This sets up a SINGLE cast on UDP, which while it WILL work, will not allow multiple clients to connect to the stream.

Instead, use an IP on the multicast subnet: https://en.wikipedia.org/wiki/Multicast_address
I showed an example above.

Then when listening on other clients (i.e., vlc) use udp://@224.0.0.1:9999 (or whichever ip you choose).
 

dnb

New Member
#6
Argh, wanted to amend my pervious post, but it's invisible until moderated...

I'd also like to state that if you want to stream to multiple RTMP servers, you will need to use an RTMP stream server.

You can use another instance of FFMPG or FFSERVER to set up streams easily.

I'd still use UDP as the source for the RTMP server for the ability of multiple clients having the ability to access a more raw stream.

UDP -> Client A
--------> Client B
--------> FFMPEG -> RTMP OUT or RTMP Server to further split (for bitrate switching)
 

Jack0r

The Helping Squad
Forum Moderator
#7
Hey, I am always happy to improve a guide, as I did not know of the multicast feature. Will update the guide.
(I mainly created it for pc to pc communication with probably no big need for more connections, but with your idea both should work fine)
 
#9
So how would I capture this udp stream from my encoding PC and re-encode it? (without vlc)
Should I still use RTMP to push to services? Like twitch?
Edit: On CentOS 7, no desktop environment.
 

Jack0r

The Helping Squad
Forum Moderator
#10
We use FFmpeg for sending and it should be able to grab the udp stream as well. It can also stream directly to an rtmp server. I would probably suggest to test how reliable ffmpeg grabs and sends the stream in this case and then decide if a rtmp server is needed.
 
#11
So we can have this as some sort of source media without VLC in OBS? or do I have the completely wrong end of the stick?

Either way, this is great work!
 
#13
So this is really useful, but as you mention there's the restrictions between container format and available encoders.

It'd be very useful to open up mpegts to an mpeg4 avc encoder. Where does the limitation come from? (Seeming it's not an ffmpeg limitation). Do you know if someone is working on it?

edit: typo
 
Last edited:
#14
I'm getting very high ping spikes ingame on both PC's when using this option, what do you think could be causing this problem? Ping on my third PC is normal. I've been testing bitrates on the UDP Stream PC and it is still spiking
 
#15
I'm getting very high ping spikes ingame on both PC's when using this option, what do you think could be causing this problem? Ping on my third PC is normal. I've been testing bitrates on the UDP Stream PC and it is still spiking
mpeg2 is many times less efficient than mpeg4 part 10. It wouldn't shock me if it's flooding some interfaces..
 

BOLL

New Member
#16
I'm very interested in getting this to work, I filled out my settings as the screenshot in the guide, do I have to add explicit muxer/video/audio encoding settings or anything else? When I try to record I get "An unspecified error occurred while recording."

I figured multicasting might be disabled on my router, an Asus AC66U, so I enabled Multicast forwarding IGMP Snooping on both LAN and Wireless and also Multicast routing IGMP Proxy, basically anything that mentioned multicast but OBS still throws the same undefined error.
 

MIB

New Member
#17
Hi,

Big Thanks! for this post, it works great with OSX, The only issue I can find is that there is no option I can find to set the TTL which I guess is set to Zero, I have solved this for my purpose by using VLC to locally receive the upd stream and re-stream via a different udp address with a TTL set which gets it to where I want.

Is there a TTL setting or can one be added ?

Thanks again!
 

Boildown

Active Member
#18
Hi,

Big Thanks! for this post, it works great with OSX, The only issue I can find is that there is no option I can find to set the TTL which I guess is set to Zero, I have solved this for my purpose by using VLC to locally receive the upd stream and re-stream via a different udp address with a TTL set which gets it to where I want.

Is there a TTL setting or can one be added ?

Thanks again!
From https://ffmpeg.org/ffmpeg-protocols.html

Looks like you can simply put in a custom command saying ttl=x , where x is whatever you want the TTL to be.
 

MIB

New Member
#19
From https://ffmpeg.org/ffmpeg-protocols.html

Looks like you can simply put in a custom command saying ttl=x , where x is whatever you want the TTL to be.
Thank you for your reply, however I have since found that it is not a TTL problem as Wireshark tells me the stream has a TTL=16 which is more than enough.

It is better if I explain the problem :- I am trying to stream directly to an Exterity IPTV Receiver (R9200) using the UDP protocol which I can make work by sheep dipping the UDP stream through VLC, this which works a treat :-) I incorrectly assumed it was a stream TTL issue as there was no setting, but it was not the problem.

I have compared the two streams OBS and routed through VLC and the main difference I can see via wire shark is as follows :-


OBS Stream [Protocols in frame: eth: ethertype: ip: udp: data]

VLC Stream [Protocols in frame: eth: ethertype: ip: udp: mp2t: mpeg-pes]


My guess is OBS is sending the video as data packets and not video, this does not seem to be a problem for VLC playback but the Exterity box does not know what to make of it, in fact it locks the box up for some time when it receives it.

Thanks again for your help.
 

xses

New Member
#20
I have some issues setting this up. OBS setup works fine but there seems to be an issue with the output. Everytime I'm opening the stream there are huge artefacts in the stream. Didn't make a screenshot yet but the stream looks something like this picture https://i.stack.imgur.com/jAJYI.png

I tried different bitrates from 2500 - 20000 it stays the same. Maybe some problems with 120hz refreshrate?
Maybe someone could help me with this. thanks in advance.
 
Top