Skip to content

m2tsmx

MPEG-2 TS multiplexer

Register name used to load filter: m2tsmx
This filter may be automatically loaded during graph resolution.

This filter multiplexes one or more input PIDs into a MPEG-2 Transport Stream multiplex.

PID selection

The MPEG-2 TS multiplexer assigns M2TS PID for media streams using the PID of the PMT plus the stream index.
For example, the default config creates the first program with a PMT PID 100, the first stream will have a PID of 101.
Streams are grouped in programs based on input PID property ServiceID if present. If absent, stream will go in the program with service ID as indicated by sid option.

  • name option is overridden by input PID property ServiceName.
  • provider option is overridden by input PID property ServiceProvider.
  • pcr_offset option is overridden by input PID property "tsmux:pcr_offset"
  • first_pts option is overridden by input PID property "tsmux:force_pts"
  • temi option is overridden by input PID property "tsmux:temi"

Time and External Media Information (TEMI)

The temi option allows specifying a list of URLs or timeline IDs to insert in streams of a program.
One or more TEMI timeline can be specified per PID.
The syntax is a comma-separated list of one or more TEMI description.
Each TEMI description is formatted as ID_OR_URL or #OPT1[#OPT2]#ID_OR_URL. Options are:

  • SN: indicate the target service with ID N
  • TN: set timescale to use (default: PID timescale)
  • DN: set delay in ms between two TEMI url descriptors (default 1000)
  • ON: set offset (max 64 bits) to add to TEMI timecodes (default 0). If timescale is not specified, offset value is in ms, otherwise in timescale units.
  • IN: set initial value (max 64 bits) of TEMI timecodes. If not set, initial value will match first packet CTS. If timescale is not specified, value is in PID timescale units, otherwise in specified timescale units.
  • PN: indicate target PID in program. Possible values are

    • V: only insert for video streams.
    • A: only insert for audio streams.
    • T: only insert for text streams.
    • N: only insert for stream with index N (0-based) in the program.
  • LC: set 64bit timecode signaling. Possible values for C are:

    • A: automatic switch between 32 and 64 bit depending on timecode value (default if not specified).
    • Y: use 64 bit signaling only.
    • N: use 32 bit signaling only and wrap around timecode value.
  • N: insert NTP timestamp in TEMI timeline descriptor

  • ID_OR_URL: If number, indicate the TEMI ID to use for external timeline. Otherwise, give the URL to insert

Example

temi="url"

Inserts a TEMI URL+timecode in the each stream of each program.
Example
temi="#P0#url,#P1#4"

Inserts a TEMI URL+timecode in the first stream of all programs and an external TEMI with ID 4 in the second stream of all programs.
Example
temi="#P0#2,#P0#url,#P1#4"

Inserts a TEMI with ID 2 and a TEMI URL+timecode in the first stream of all programs, and an external TEMI with ID 4 in the second stream of all programs.
Example
temi="#S20#4,#S10#URL"

Inserts an external TEMI with ID 4 in the each stream of program with ServiceID 20 and a TEMI URL in each stream of program with ServiceID 10.
Example
temi="#N#D500#PV#T30000#4"

Inserts an external TEMI with ID 4 and timescale 30000, NTP injection and carousel of 500 ms in the video stream of all programs.

Warning: multipliers (k,m,g) are not supported in TEMI options.

Adaptive Streaming

In DASH and HLS mode:

  • the PCR is always initialized at 0, and flush_rap is automatically set.
  • unless nb_pack is specified, 200 TS packets will be used as pack output in DASH mode.
  • pes_pack=none is forced since some demultiplexers have issues with non-aligned ADTS PES.

The filter watches the property FileNumber on incoming packets to create new files, or new segments in DASH mode.
The filter will look for property M2TSRA set on the input stream.
The value can either be a 4CC or a string, indicating the MP2G-2 TS Registration tag for unknown media types.

Notes

In LATM mux mode, the decoder configuration is inserted at the given repeat_rate or CarouselRate PID property if defined.

Options

breq (uint, default: 100): buffer requirements in ms for input PIDs
pmt_id (uint, default: 100): define the ID of the first PMT to use in the mux
rate (uint, default: 0): target rate in bps of the multiplex. If not set, variable rate is used
pmt_rate (uint, default: 200): interval between PMT in ms
pat_rate (uint, default: 200): interval between PAT in ms
first_pts (luint, default: 0): force PTS value of first packet, in 90kHz
pcr_offset (luint, default: -1): offset all timestamps from PCR by V, in 90kHz (default value is computed based on input media)
mpeg4 (enum, default: none): force usage of MPEG-4 signaling (IOD and SL Config)

  • none: disables 4on2
  • full: sends AUs as SL packets over section for OD, section/pes for scene (cf bifs_pes)
  • scene: sends only scene streams as 4on2 but uses regular PES without SL for audio and video

pmt_version (uint, default: 200): set version number of the PMT
disc (bool, default: false): set the discontinuity marker for the first packet of each stream
repeat_rate (uint, default: 0): interval in ms between two carousel send for MPEG-4 systems (overridden by CarouselRate PID property if defined)
repeat_img (uint, default: 0): interval in ms between re-sending (as PES) of single-image streams (if 0, image data is sent once only)
max_pcr (uint, default: 100): set max interval in ms between 2 PCR
nb_pack (uint, default: 4): pack N TS packets in output packets
pes_pack (enum, default: audio): set AU to PES packing mode

  • audio: will pack only multiple audio AUs in a PES
  • none: make exactly one AU per PES
  • all: will pack multiple AUs per PES for all streams

realtime (bool, default: false): use real-time output
bifs_pes (enum, default: off): select BIFS streams packetization (PES vs sections)

  • on: uses BIFS PES
  • off: uses BIFS sections
  • copy: uses BIFS PES but removes timestamps in BIFS SL and only carries PES timestamps

flush_rap (bool, default: false): force flushing mux program when RAP is found on video, and injects PAT and PMT before the next video PES begin
pcr_only (bool, default: false): enable PCR-only TS packets
pcr_init (lsint, default: -1): set initial PCR value for the programs. A negative value means random value is picked
sid (uint, default: 0): set service ID for the program
name (str): set service name for the program
provider (str): set service provider name for the program
sdt_rate (uint, default: 0): interval in ms between two DVB SDT tables (if 0, SDT is disabled)
temi (str): insert TEMI time codes in adaptation field
log_freq (uint, default: 500): delay between logs for realtime mux
latm (bool, default: false): use LATM AAC encapsulation instead of regular ADTS
subs_sidx (sint, default: -1): number of subsegments per sidx (negative value disables sidx)
keepts (bool, default: false): keep cts/dts untouched and adjust PCR accordingly, used to keep TS unmodified when dashing