• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D12-Jun-201893 119

AUTHORSH A D12-Jun-2018574 2218

COPYINGH A D12-Jun-201817.7 KiB341281

ChangelogH A D12-Jun-2018430 127

INSTALLH A D12-Jun-2018614 2415

MakefileH A D03-May-20222.4 KiB7352

NEWSH A D12-Jun-20182.2 KiB5046

READMEH A D12-Jun-20187.9 KiB230152

aggregartp.1H A D12-Jun-20181.4 KiB4847

aggregartp.cH A D12-Jun-201816.8 KiB528406

ingests.1H A D12-Jun-20181.1 KiB3635

ingests.cH A D12-Jun-20188.6 KiB283192

ingests_debug.cH A D12-Jun-20182.2 KiB6534

lasts.1H A D12-Jun-2018918 2726

lasts.cH A D12-Jun-20183.1 KiB10264

multicat.1H A D12-Jun-20182.7 KiB8684

multicat.cH A D03-May-202238.4 KiB1,2981,042

multicat_expire.shH A D12-Jun-20181.6 KiB4818

multicat_validate.cH A D12-Jun-20186.3 KiB218157

multilive.cH A D12-Jun-201810.6 KiB343262

offsets.1H A D12-Jun-20181,018 2726

offsets.cH A D12-Jun-20182.1 KiB6833

reordertp.1H A D12-Jun-20181.3 KiB4544

reordertp.cH A D12-Jun-201823.3 KiB731574

util.cH A D03-May-202239.9 KiB1,255989

util.hH A D03-May-20226.3 KiB180119

README

1Welcome to Multicat!
2====================
3
4The multicat package contains a set of tools designed to easily and
5efficiently manipulate multicast streams in general, and MPEG-2
6Transport Streams (ISO/IEC 13818-1) in particular.
7
8The multicat tool itself is a 1 input/1 output application. Inputs and
9outputs can be network streams (unicast and multicast, IPv4 and IPv6), files,
10directories, character devices or FIFOs. Typical applications are recording
11live transport streams, or playing out TS files without modification.
12
13Multicat tries to rebuild the internal clock of the input stream; but
14it wants to remain agnostic of what is transported, so in case of files
15or directories, the said clock is stored to an auxiliary file (example.aux
16accompanies example.ts) while recording. Other inputs are considered "live",
17and the input clock is simply derived from the reception time of the
18packets.
19
20IngesTS is a companion application designed to manipulate TS files. It
21reads the PCR values of the file, and builds the auxiliary file that is
22necessary for multicat.
23
24OffseTS is another companion application to manipulate auxiliary files.
25Given an offset in time from the beginning of the file, it returns the offset
26of the position in number of packets. It is currently deprecated in favour of
27using the -k and -d options of multicat.
28
29LasTS is also a companion application which gives the total duration of an
30auxiliary file.
31
32Finally aggregaRTP and reordeRTP can be used to carry a high-bitrate
33signal over one or several contribution links, and support retransmission
34of lost packets via an additional UDP or TCP connection. ReordeRTP can also
35smooth up the reception of a stream from a link that is known to reorder
36and add jitter to packets.
37
38The multicat suite of applications is very lightweight and designed to
39operate in tight environments. Memory and CPU usages are kept to a minimum,
40and they feature only one thread of execution.
41
42
43The socket description format
44=============================
45
46For conveniency all tools use the same way of describing a socket in a
47program argument:
48
49<connect address>:<connect port>@<bind address>:<bind port>/<options>
50
51All parts are optional; default port (1234) or wildcard address will then
52be used.
53
54Some examples:
55
56Reading all streams coming to port 5004:
57    @:5004
58Reading from a multicast stream on port 5004:
59    @239.255.0.1:5004
60The same, with source-specific multicast:
61    192.168.0.1@239.255.0.1:5004
62Writing to a multicast stream on port 5004:
63    239.255.0.1:5004
64The same, but binding to a specific interface:
65    239.255.0.1:5004@192.168.0.2
66
67Options include:
68 /ifindex=X (binds to a specific network interface, by link number)
69 /ifaddr=XXX.XXX.XXX.XXX (binds to a specific network interface, by address)
70 /ttl=XX (time-to-live of the UDP packet)
71 /tos=XX (sets the IPv4 Type Of Service option)
72 /tcp (binds a TCP socket instead of UDP)
73 /srcaddr=XXX.XXX.XXX.XXX (source address for raw packets)
74 /srcportr=XX (source port for raw packets)
75
76Example:
77    239.255.0.1:5004/ttl=64
78
79Also, multicat supports IPv6 addresses.
80
81
82Basic uses
83==========
84
85Recording a multicast address to a file:
86
87multicat @239.255.0.1:5004 /tmp/myfile.ts
88
89This will also create file /tmp/myfile.aux. Playing back the file:
90
91multicat -p 68 /tmp/myfile.ts 239.255.0.2:5004
92
93Adding an RTP header to an existing multicast stream:
94
95multicat -p 68 -u @239.255.0.1:5004 239.255.0.2:5004
96
97The PCR PID is here supposed to be 68. If you don't specify it, the timestamps
98will not be RFC-compliant (but will work in most cases). You can use the
99mpeg_print_pcr example from biTStream to determine it. Otherwise, if you are
100sure the stream contains a single program, and only one PID carries a PCR, you
101can pass "-p 8192" the disable the PID check. This isn't on by default because
102it can produce awful things with multi-program transport streams, and the
103world would be a better place if people had to knowingly turn it on.
104
105Starting at a given position for a given duration:
106
107multicat -p 68 -k 270000000 -d 2700000000 /tmp/myfile.ts 239.255.0.2:5004
108
109In this case multicat discards the first 10 seconds, and only plays the file
110for 100 seconds. Internally multicat uses a 27 MHz monotonic clock, and all
111offsets (starting from 0) and durations are expressed in this unit.
112
113Making an extract of a recorded file to a plain TS file:
114
115multicat -f -k 270000000 -d 2700000000 /tmp/myfile.ts /tmp/extract.ts
116
117The option -f allows outputting the extract as fast as the output item can
118write it, without reproducing the same pace as the original stream (and thus,
119waiting 100 seconds).
120
121
122Using IngesTS
123=============
124
125ingests -p 68 /tmp/afile.ts
126
127This will create file /tmp/afile.aux. 68 is supposed to be the PCR PID.
128The same note as above applies to ingesTS.
129
130Playing the file:
131
132multicat -p 68 /tmp/afile.ts 239.255.0.2:5004
133
134
135Working with directories
136========================
137
138Starting with version 2.0, multicat can write or read a continuous stream to
139discontinuous buffers, while still retaining the original properties. For
140instance:
141
142mkdir mydir
143multicat @239.255.255.1:5004 mydir
144
145creates file XXXXXX.ts and XXXXXX.aux in mydir. Every hour, multicat closes
146both files, and creates (XXXXXX+1).ts and (XXXXXX+1).aux. And so one. The
147stream can then be identically replayed with a 100 seconds delay with:
148
149multicat -p 68 -k -2700000000 mydir 239.255.255.2:5004
150
151A negative value to -k implies "from the end", in this case from the present
152time. To make an extract of the stream:
153
154multicat -f -k 35383033980000000 -d 27000000000 mydir extract.ts
155
156With the directory input/output, timestamps represent the number of ticks of
157a 27 MHz real-time clock since the 1st of January 1970 (UNIX Epoch). It is
158therefore possible to pass absolute (positive) dates to -k.
159
160There is no built-in expiration of files in multicat; to avoid filling up the
161partition, it is necessary to run multicat_expire.sh every hour.
162
163The duration of the segments may be specified with -r. It is also advised to
164add an offset with -O (typically a per-stream random number of up to the
165segment duration minus one) to avoid having all multicat processes rotate
166files exactly at the same time, resulting in a surge in CPU usage and disk I/O.
167
168
169Using OffseTS
170=============
171
172We want to take the first 60 minutes of a TS file. We must scale it in a
17327 MHz clock:
17460 * 60 (seconds) * 27000000 (MHz) = 97200000000
175
176Find the offset in 1316-blocks:
177
178offsets /tmp/myfile.aux 97200000000
179
180It returns for instance "556896". Then cut the file using dd:
181
182dd if=/tmp/myfile.ts of=/tmp/mynewfile.ts bs=1316 count=556896
183
184Alternatively, if we want to *remove* the first hour:
185
186dd if=/tmp/myfile.ts of=/tmp/mynewfile.ts bs=1316 skip=556896
187
188It can also be done with multicat using the -s and -n options.
189
190OffseTS is currently deprecated in favour of using the -k and -d options of
191the multicat program. OffseTS is still distributed for compatibility, but
192doesn't support the new directory input.
193
194
195Using AggregaRTP and ReordeRTP
196==============================
197
198Splitting an RTP stream to two streams with different routing policies:
199
200aggregartp @239.255.0.1:5004 239.1.0.1:5004@192.168.0.1 239.2.0.1:5004@172.16.0.1
201
202At the other end, reassembling the two streams into one usable stream:
203
204reordertp 192.168.0.1@239.1.0.1:5004 172.16.0.1@239.2.0.1:5004 239.254.0.1:5004
205
206Transmit a signal over a lossy link:
207
208aggregartp @239.255.0.1:5004 239.1.0.1:5004 -X @:5006
209reordertp @239.1.0.1:5004 239.254.0.1:5004 -X 192.168.0.1:5006
210
211The same, but using inverted TCP for retransmission (for NAT traversal for
212instance):
213reordertp @239.1.0.1:5004 239.254.0.1:5004 -X @:5006/tcp
214aggregartp @239.255.0.1:5004 239.1.0.1:5004 -X 192.168.0.2:5006/tcp
215
216(with TCP the listener must be started before the other)
217
218
219Using multilive
220===============
221
222Running a master at priority 1000 on multicast address 239.255.255.255:1025:
223
224multilive -y 1000 @239.255.255.255:1025 239.255.255.255:1025
225
226Running another master on a different machine at a higher priority (who will
227preempt the other master):
228
229multilive -y 1001 @239.255.255.255:1025 239.255.255.255:1025
230