Skip to content

Sending a Multicast

When working with IPTV, one often has to deal with videos transmitted as multicasts. In most cases, a multicast contains an MPEG-TS container (7 188-byte packets in each UDP packet). Less frequently, the RTP video in transmitted into the network that contains the same MPEG-TS. RTP is needed to make it possible to track the losses, since the RTP packet contains a 16-bit counter that is used to track sequence numbers.

Brief basics of multicast

A multicast is a set of UDP packets distributed from the same source to a group of subscribers. The address to which packets are sent is usually in the range between 224.0.0.0 and 239.255.255.255, however, 224.0.0.0/8 is not recommended due to the large number of special addresses.

In a properly configured network, multicast traffic is sent to the nearest router, and the router itself chooses the client to send the traffic to, based on the requirements of the clients. The requirements are transmitted via the IGMP protocol that is used for transmitting messages about the need to include some address into the distribution group, or exclude it from the group.

Therefore, in order to make Flussonic send multicast to client devices, it is necessary to make it send the packets to the proper interface (in a local operator network), and the router should be configured to work correctly with multicast.

Ingesting of multicast streams is described in Receiving multicast.

Configuring Flussonic

To configure a multicast distribution, it is enough to specify the push option in stream settings. The push option specifies the multicast address:


stream origin {
  input fake://fake;
}
stream example {
 input hls://localhost:80/origin/index.m3u8;
 push udp://239.0.0.1:1234;
}

You can also create a stream via the web interface: create a new stream, specify the source URL (on the Input tab) and add the multicast address udp://239.0.0.1:1234 in the stream settings (on the Output tab in the section Push live video to certain URLs).

Selecting tracks

You can select what tracks to send:


stream origin {
  input fake://fake;
}
stream example {
 input hls://localhost:80/origin/index.m3u8;
 push udp://239.0.0.1:1234?tracks=v1a1;
}

Here, v1 stands for the 1st video track and a1 for the 1st audio track.

Maximum bitrate

Flussonic can push multicast with maximum bitrate value in PMT (Program Map Table) for every ES (Elementary Stream). To enable this option you have to add the es_max_bitrate=default string to the query string. The configuration may look as follows:


stream example {
  input file://vod/STREAM_NAME.ts;
  push udp://239.0.0.1:1234?cbr=6000&tracks=v1a1&es_max_bitrate=default;
  transcoder vb=5000k fps=25 preset=fast hw=cpu ab=192k;
}

Interface name

If you do not remember the IP address of the interface from where the multicast will be sent, you can specify its name:


push udp://eth0@239.0.0.1:1234

instead of


push udp://239.0.0.1:1234/10.0.0.5

Example:


stream example {
  input hls://provider.iptv/stream/index.m3u8;
  push udp://eth0@239.0.0.1:1234;
}

Here eth0 is the name of the interface that looks into a local network.

Looping back a multicast stream to the Flussonic host

If you push a stream from Flussonic to UDP multicast, you can use the multicast socket option multicast_loop that enables ingesting the sent UDP data back to the Flussonic host:


stream example_push {
  input hls://provider.iptv/stream/index.m3u8;
  push udp://239.0.0.1:1234 multicast_loop;
}

stream example_ingest {
  input udp://239.0.0.1:1234;
}

This option allows you to ingest the sent stream on the sending host by Flussonic or other application.

Configuring the server

After you set up multicasting, chances are that nothing will work, since very often, due to server settings, multicast traffic is sent to the first interface, which usually looks into the Internet. You need to make Flussonic start sending traffic to an interface that looks into a local network.


route add -net 239.0.0.0/8 dev eth2

Here, eth2 is the name of the interface connected to the local network. After you set up routing in this way, the multicast from Flussonic will be routed to the proper interface, and you can check it at the router, and at the client.

Specifying PIDs

When sending MPEG-TS to UDP multicast (push udp://), specify PIDs by using the option mpegts_pids.

Another way to specify PIDs is as follows:


stream example {
  input hls://provider.iptv/stream/index.m3u8;
  push udp://239.1.2.4:1235 bitrate=7000 pnr=2 vb=6000 pmt=2000 v1=2011 a1=2021;
}

Signalling AC-3 audio stream in MPEG-TS #play-multicast-mpegts_ac3}

MPEG-TS containing AC-3 elementary audio stream is regulated by the STD (System Target Decoder) model in System A (ATSC) or System B (DVB). Signaling formats in System A (ATSC) and System B (DVB) vary substantially. So uniquely identifying AC-3 streams is used not only to indicate unambiguously that an AC-3 stream is an AC-3 stream, but to which System (A or B) the stream belongs.

Flussonic can read different signaling formats of AC-3 elementary stream in PMT. Flussonic can either pass the original signaling format of AC-3 stream in MPEG-TS to UDP multicast or convert the format to comply with System A or System B with the help of the mpegts_ac3 option. This option is specified in the stream/template settings, and takes the following values:

  • mpegts_ac3 keep — keeps the original AC-3 audio stream signaling format passing it to the output
  • mpegts_ac3 system_a — modifies the AC-3 signaling format to match System A
  • mpegts_ac3 system_b — modifies the AC-3 signaling format to match System B

Note

If an input and output audio is in AC-3 format, you don't have to enable transcoding to use the mpegts_ac3.

Consider the following configuration:


stream example-stream {
  input udp://MULTICAST-IP-1:PORT-1 programs=2;
  push udp://MULTICAST-IP-2:PORT-2 bitrate=6800;
  mpegts_ac3 keep;
}

Here Flussonic ingests a UDP stream with AC-3 audio and pushes the UDP stream with the original audio signaling format to the output.