I have a closed third party system that sends a unicast UDP stream (MPEG-TS) that I'd like to access in two different programs on the same computer. I can not change anything on the source, not even IP or Port.
Is there any other option than to write my own little program that captures the stream and then creates to new streams and resends both?
It seems that only one of the two destination programs handles multicast, so I need two unicast streams.
You should be able to use socat
to forward unicast UDP to a multicast group, or just save data into a file and process later.
Edit 0:
Here is an example (this is on Linux - don't have any Windows boxes). Listen on unicast port 4242
, forward to multicast 224.10.10.10:5252
(you might have to add ip-multicast-loop
option if you are doing everything on the same machine):
~$ socat UDP-LISTEN:4242 UDP-DATAGRAM:224.10.10.10:5252
Receive on multicast (needs interface address or name), forwards to unicast 192.168.0.1:6666
:
~$ socat UDP-RECVFROM:5252,ip-add-membership=224.10.10.10:eth0,reuseaddr,fork \
UDP-DATAGRAM:192.168.0.1:6666
Run two of the above with different destination addresses (reuseaddr
option allows these to be run on the same machine).
来源:https://stackoverflow.com/questions/12564580/how-to-receive-the-same-udp-stream-in-several-programs