Stream over UDP¶
This page explains how VLC Media Player can be used to stream a file locally over UDP. Streaming locally means that the streaming device and all the receiving device(s) should be present in the same local network (so they should be connected to the same router) for the streaming to work.
To stream a media file over UDP, make the following modifications in the std
block:
Set
access=udp
, andSet
dst=address:port
(whereaddress
is the IP address of the receiving device).
The destination IP address can be:
A unicast address (when streaming to a specific device), or
A multicast address (when streaming to multiple device in the network).
You can pick any port number to stream (except for a few reserved ports). For this example, we will stream on port number 8090
.
For this example, let’s assume that the network IP addresses of the devices involved are:
Streaming device: 192.168.0.101
Receiving device(s): 192.168.0.102, 192.168.0.103, 192.168.0.104
Multicast address: 239.255.255.250
Unicast streaming using UDP¶
Sending a Unicast Stream¶
To start streaming, run the following code in the streaming device:
$ vlc sample.mp4 --sout="#std{access=udp, mux=ts, dst=192.168.0.102:8090}"
Notice that the IP address in dst
is the IP address of the receiving device.
Receiving a Unicast Stream¶
To receive the stream, run the following code on the receiving device:
$ vlc udp://@:8090
Alternatively, you could run the following code which will accomplish the same thing as the one above:
$ vlc udp://@192.168.0.102:8090
You can read his page for a more in-depth explanation of how the UDP URL works in VLC.
In unicast streaming over UDP, a simplified representation of the network would looks something like this:
Multicast streaming using UDP¶
Streaming to the multicast IP address essentially means that the stream will the pushed to all the devices in the local network. So any device that wishes to receive the stream can connect to the relevant port and start receiving.
Sending a Multicast Stream¶
To start a multicast stream, run the following code on the streaming device:
$ vlc sample.mp4 --sout="#std{access=udp, mux=ts, dst=239.255.255.250:8090}"
Here, we have used the multicast
IP address for the dst
parameter.
Receiving a Multicast Stream¶
To receive the stream, run the following code on all the receiving devices:
$ vlc udp://@239.255.255.250:8090
In this case, we need to use the multicast IP address to receive the stream.
The network would might look something like the following. Notice that as udp is a push
protocol, it pushes the stream to all the devices in the local network.
Using a SAP session¶
When streaming over UDP, you can use SAP announcements. This will help to “discover” streams on the receiving devices and seamlessly connect without having to execute any code. Refer to Using SAP while Streaming to understand how to use SAP announcements.
Alternate syntax¶
Instead of using the #std{access=udp
syntax, we can use the alternate syntax #udp{
to stream over UDP. The alternate syntax is just a stortcut for calling the access=udp
part of the std
module, so all the other parameters remain the same.
Hence, the following code:
$ vlc sample.mp4 --sout="#std{access=udp, mux=ts, dst=192.168.0.102:8090}"
is equivalent to:
$ vlc sample.mp4 --sout="#udp{mux=ts, dst=192.168.0.102:8090}"
Streaming in IPv6¶
Streaming and Receiving in IPv6 in unicast and multicast¶
The syntax to stream and receive unicast or multicast UDP streams with VLC is almost the same as the IPv4 syntax. The only difference is that you have to wrap the IPv6 address with brackets.
Examples:
$ vlc sample.mp4 --sout="#udp{mux=ts, dst=[2a01:cb04:482:5242::42]:8090}"
Will send a UDP MPEG-TS stream to the device with the IPv6 2a01:cb04:482:5242::42
on the port 8090.
$ vlc udp://@[ff13::42]:1234
Will join the FF13::42
multicast group in IPv6 and capture any packet sent on the port 1234.
On IPv6 Multicast ranges and selection for streaming¶
Multicast address is defined in IPv6 in the range FF00::/8
.
The full format description follows the scheme:
8 |
4 |
4 |
112 bits |
11111111 |
flgs |
scop |
group ID |
flgs : defines special flags related to the multicast group. For streaming purpose, you should use the single 1 value (temporary multicast address). See the related RFC4291 section for more details about multicast flags.
scop : defines the “scope” of the multicast group, which describes up to where the group should be spanned. Notable scopes that can be used for local streaming are:
1
for interface-local (restricted to the machine, for purely “localhost” streaming)2
for link-local (related to the link-local addresses, so restricted to the closest peers)3,4,5,8
for respectivelyrealm-local
,admin-local
,site-local
andorganization-local
which are different levels of span. For a complete list of scopes, see The related RFC7346 section.
Note
For a simple UDP multimedia stream over multicast IPv6 that will be spanned on a LAN, good candidates are the ranges FF13::/16
, FF14::/16
, FF15::/16
or FF18::/16
.
For more information on multicast IPv6 address format, read This section of RFC4291.