SPTS streams¶
SPTS (Single Program Transport Stream) is an MPEG-TS stream carrying a single programme; it is the basic processing unit of Perfect Streamer. The stream type — SPTS or MPTS — is selected at creation time and cannot be changed later. An SPTS stream additionally has a content type (values as shown in the interface): Default (audio + video), Audio only (sound without video, radio channels) or Video only.
Scrambled (encrypted) streams are supported: scrambling is detected automatically, and elementary-stream checks are suspended for that time. The “Scrambled channel” setting declares the stream permanently scrambled and disables auto-detection.
The general requirements for the input stream are listed in Input stream requirements; the reception and transmission protocols are covered in Planning and data transmission protocols. Multiplex processing is described in MPTS streams. Streams are created and configured in the web interface (Streams).
Processing pipeline¶
SPTS stream pipeline: inputs, stream-level processing (input switch, TS filter, analyzer, bitrate shaping, synchronizer), the OTT / DVR subsystem and outputs.¶
All inputs of a stream converge on the input switch, after which the stream passes through the successive processing stages:
Input switch — selects the active source and switches the stream to a backup on failure (Source redundancy).
TS filter — optional MPEG-TS filtering and modification (MPEG-TS filtering, Stream modification).
Analyzer — continuous validity checking and measurement of the stream (Analyzer); it is the analyzer verdict on which the input switch declares a source failed. Analyzer data is also used by the mosaic (Mosaic, disabled by the “Generate mosaic” setting), by EPG import and by the subtitle decoder.
Bitrate shaping — optional stuffing to a constant bitrate and PAT/PMT interval correction (Bitrate control).
Synchronizer — packet output paced by PCR with network-jitter compensation (Synchronization). This is also where the EIT generator inserts the programme-guide tables (EIT generator).
From the synchronizer output the stream is distributed to all outputs: transport protocols (Peer protocols for reliable transmission), file recording, the MPTS multiplexer (Multiplexer), the transcoder (Transcoders), and the OTT / DVR subsystem (OTT and DVR). An SPTS stream may also be sourced from an individual programme of a multiplex — a demultiplexer input (type demuxer) extracts it from an MPTS stream or from a DVB receiver by programme number (Demultiplexer).
Source redundancy¶
A stream may have several inputs, but only one of them is ever active. The order of the inputs in the list defines their priority: the first is the primary input, the rest are backups. If the active input is declared failed, the stream switches to the next input in the list; after the last input the search wraps around to the first. An input that has been paused is skipped when switching.
Failure is determined by the analyzer: an input is considered failed if the stream does not pass the validity check or if no data arrives for longer than the configured timeout. Operation of the stream on a backup input is recorded by an alert (Alerts (alerter)).
The switching settings are on the “Stream” tab of the stream editor (Configure stream):
- “Stream timeout (s)”
The time without a valid input stream after which the switch to the next input is performed. 30 seconds by default.
- “Check interval (s)”
The period at which the sources are re-probed. 60 seconds by default.
- “Re-probe primary input”
While the stream is running on a backup input, the inputs higher in the list are re-probed at the check interval. As soon as a higher-priority source becomes valid again, the stream returns to it. Enabled by default.
MPEG-TS filtering¶
By default the stream is passed through as is. Filtering is applied at two levels: the PID rules per input, and the table filters at stream level.
The PID rules are configured on the “MPEG-TS PID” tab of the input window (Input and output editor):
- “Accept PIDs (white-list)”
The list of permitted PIDs. If the list is empty, everything is permitted except what the black-list forbids.
- “Reject PIDs (black-list)”
The list of forbidden PIDs. A PID present in both lists at once is rejected.
After filtering, the PMT is regenerated from the actual set of elementary streams. The PID rules are applied before automatic PID arrangement (Automatic PID arrangement), if it is enabled.
The stream-level filters are on the “MPEG-TS” tab of the stream editor, section “Filters” (all disabled by default):
- “Clean unnecessary tables”
Removes service data not belonging to the programme and elementary streams of unknown types; streams of known types (video, audio, teletext, subtitles) and the PAT/PMT tables are retained. Individual tables (SDT, EIT, NIT, TDT, CAT) are controlled by their own filters.
- “Delete CAT / ECM / EMM”
Removes conditional-access system (CAS) tables and messages, including the CA descriptors in the PMT — for example, to clear the CAS residue left after descrambling.
- “Delete EIT”
Removes the programme-guide tables of the source. By default the EIT passes through.
- “Delete NIT”, “Delete TDT”
Remove the network and time-stamp tables of the source.
- “Delete teletext”, “Delete subtitles”
Remove the teletext and DVB subtitle streams together with their entries in the PMT.
- “Delete origin SDT” (section “SDT”)
Removes the service description table of the source — for example, when the stream is passed on for further multiplexing. When an own service name is assigned (Stream modification), the original SDT is replaced automatically and this filter does not have to be enabled separately.
Note
Removing the mandatory tables (SDT, NIT, TDT, EIT, CAT) violates the TR 101 290 requirements for their presence in the stream — this is a deliberate decision of the operator, appropriate for example when the stream is passed on for further multiplexing. In addition, any filtering changes the packet composition of the stream; for the effect on PCR accuracy see Bitrate control.
Stream modification¶
Own service data is set in the “SDT” section of the “MPEG-TS” tab. Table generation is enabled by the “Service name” field (and also by active EIT generation from EPG): if the source has no SDT, the table is generated; if it has one, it is replaced by the generated table. The “Provider name” and “Language” fields populate the corresponding fields of the generated table. The “Network id” setting specifies the network identifier for the generated EIT tables when the source does not report a network identifier of its own; if the source does carry one, that identifier is used.
The programme number is remapped in the “Programme number” section: enable “Change programme number” and set “New programme number”. The PAT and PMT are regenerated with the new number; the SDT and EIT are regenerated as well.
“Fix PAT/PMT interval” regenerates the PAT/PMT and inserts them at an interval compliant with TR 101 290. Use it with sources whose tables are infrequent or irregular.
PID and language remapping is performed on the input, on the “MPEG-TS PID” tab of the input window:
- “Remap PIDs”
“From PID” / “To PID” pairs — replacement of the elementary-stream identifiers, for example to bring the stream in line with the network PID plan. When automatic PID arrangement (Automatic PID arrangement) is enabled, these pairs have no effect.
- “Remap audio language”
“Audio PID” / “New language” pairs — replacement of the audio track language in the PMT.
EIT generation from an external EPG source is enabled in the “Generate EIT from EPG” section of the “Stream” tab: select the “EPG source” and the “EPG channel”, and EIT tables carrying the programme guide are inserted into the stream (EIT generator). The reverse operation is the “Extract EIT to EPG database” setting, which exports the programme guide from the stream into the EPG database of the node (EPG/XMLTV import).
Inputs that receive a raw transport stream support software BISS descrambling: a BISS-1 or BISS-E key is set on the input, and the stream is decrypted before analysis and further processing. Reception of scrambled services from a DVB receiver (CAM, BISS at adapter level) is described in DVB receiver.
Automatic PID arrangement¶
By default the elementary-stream identifiers pass from the source to the output stream unchanged, so when the stream switches to a backup input the PID arrangement at the output follows the source. Automatic arrangement assigns the PIDs itself, by one and the same rule for every input: the PID plan of the output stream stays unchanged no matter which source is currently active.
The mode is available for SPTS only and is enabled in the “MPEG-TS” section of the “MPEG-TS” tab of the stream editor:
- “Automatic PID arrangement”
Enables the mode.
- “Base PID”
The first PID of the window: from 32 to 8127, 32 by default. The lower bound puts the window outside the range reserved for the PSI/SI tables, the upper bound keeps the whole window below the PID of the null packets.
The program is renumbered into a window of 64 PIDs that starts at the base PID:
PID |
Purpose |
|---|---|
base |
PMT |
base + 1 |
video |
next |
audio tracks |
next |
the remaining elementary streams: teletext, DVB subtitles, data, SCTE-35 |
next |
PCR, if it is not carried in one of the streams listed above |
next |
ECM: first from the program-level descriptors, then from the descriptors of the individual streams |
from the end of the window downwards |
EMM |
Within each group the order of the original PMT is preserved. If the program has no video, the arrangement is compacted: the first audio track follows the PMT directly. The EMM are allocated from the end of the window, because the CAT is parsed independently of the PMT and may arrive earlier — their addresses must not depend on the number of elementary streams.
The PAT, PMT and CAT are rebuilt for the new arrangement. The SDT, NIT, EIT and TDT are left unchanged: they contain no PID references.
What to keep in mind when enabling the mode:
The mode forcibly enables MPEG-TS filtering, so PIDs that are not declared in the PMT and the CAT no longer pass through. A stream that relied on undeclared PIDs being carried through will lose them.
Manual PID remapping on the inputs has no effect and is ignored, with a warning written to the log. The web interface hides those fields while the mode is on; the saved pairs are not lost and come back when it is switched off.
The PID accept and reject lists keep working and are applied before the renumbering: only the surviving elementary streams get a slot, and no gaps are left in the window (MPEG-TS filtering).
The mode does not apply to the transcoder input (Transcoders) or the test-generator input (Test streams): there the PID plan is built by the encoder or the generator, so their own PMT PID fields remain available.
If the program does not fit into the window, no renumbering is performed at all — the arrangement stays as it was and a warning goes to the log; a half-renumbered stream is never emitted.
A change to either of the two settings is applied on the fly: the stream itself is not restarted, but its inputs and outputs are brought back up — a few seconds for resynchronization.
In the stream statistics the “Media information — source” block shows the PIDs that arrived at the input, while “Media information — result” and the per-PID bitrate table show the assigned ones; with the mode enabled a discrepancy between them is normal.
Automatic PID arrangement is unrelated to PID assignment in the MPTS multiplexer (PID mapping) — that is a separate setting of the muxer input.
Bitrate control¶
The bitrate control mode is set by the “Bitrate mode” field on the “MPEG-TS” tab (values as shown in the interface):
- Original (default)
The stream is passed through unchanged; the source PCR stamps are not recalculated.
- VBR
Removes the NULL packets of the source, which minimizes the bitrate. Suitable when the stream is used for OTT delivery or transit only. The PCR stamps are not recalculated in this mode, so TR 101 290 PCR accuracy at the output is not guaranteed.
- CBR (auto stuffing)
Levels the bitrate to a constant value by inserting NULL packets (stuffing). The target bitrate is determined automatically: it is fixed a few seconds after the mode is enabled, is raised on a sustained overshoot and is lowered gradually if the content peak stays below the target for a long time. A change of target does not interrupt stream output.
- CBR (explicit stuffing)
The same, but the target bitrate is set explicitly by the “Stuffing bitrate (kbps)” field. Set the value with a margin above the actual content bitrate.
In the CBR modes the PCR stamps are recalculated from the bytes actually transmitted, so the output meets the TR 101 290 requirements for PCR accuracy. In addition, while stuffing is active the PCR repetition rate at the output is kept within specification even on long video frames. In this case the analyzer measures exactly the emitted, levelled stream (Analyzer).
When CBR is required. Any operation that inserts or removes packets — the table and PID filters, SDT and EIT generation, PAT/PMT interval correction, a change of the programme number, and the VBR mode itself — shifts the position of the content relative to its PCR stamps. If the receiver of the stream requires TR 101 290 compliance, for DVB broadcasting for example, enable a CBR mode: stuffing masks these changes by recalculating the PCR. For a stream downstream of the transcoder, enable a CBR mode on the receiving stream (PCR and the bitrate of the output stream).
The current stuffing state — the target bitrate and the NULL-packet insertion rate — is shown in the active input data on the stream page (Streams, section “Stuffing”; the section is visible only while stuffing is active).
Synchronization¶
The synchronizer emits packets to the outputs at the pace of the source PCR stamps — valid PCR is therefore mandatory for the input stream. Between reception and output the stream is delayed in a jitter buffer, which smooths out the irregular arrival of packets from the network.
The buffer is configured separately on each input (input window, Input and output editor; advanced settings, names as shown in the interface):
- Auto jitter buffer
Automatic selection of the delay according to the input type: TCP and HLS inputs use an enlarged buffer, all others the standard one. Enabled by default.
- Jitter buffer (ms)
The buffer size set manually, when the automatic mode is disabled (500 ms by default). Increase the value if the buffer runs empty regularly on an unstable network.
- PCR discontinuity window (ms)
The window of the permissible PCR jump (1000 ms by default). A jump beyond the window is treated as a stream discontinuity and triggers a hard resynchronization.
A slow divergence between the source PCR pace and the node clock is eliminated by the drift compensator: the correction is applied smoothly, in micro-shifts, without a hard resynchronization and without interrupting the output. It is controlled on the “Analyze” tab of the stream editor: “Sync drift compensation” (enabled by default) and “Sync drift soft window (ms)” — the dead zone within which no correction is applied (500 ms by default). Hard resynchronization remains the fallback mechanism for genuine stream discontinuities.