# `Membrane.MPEG.TS.Demuxer`
[🔗](https://github.com/kim-company/membrane_mpeg_ts_plugin/blob/main/lib/membrane/mpeg/ts/demuxer.ex#L1)

Demuxes MPEG TS stream.

After transition into playing state, this element will wait for [Program
Association Table](https://en.wikipedia.org/wiki/MPEG_transport_stream#PAT)
and [Program Mapping
Table](https://en.wikipedia.org/wiki/MPEG_transport_stream#PMT).

For `:H264_AVC` streams, the demuxer emits `%Membrane.H264{alignment: :au,
stream_structure: :annexb}` and assumes each PES contains exactly one access
unit.

Use `profile:` to select streams that require descriptors and depacketization
(e.g. Opus in MPEG-TS). For custom payloads, match `stream_type:` and
`registration_descriptor:` explicitly.
## Element options

Passed via struct `t:Membrane.MPEG.TS.Demuxer.t/0`

- `strict?`  

  ```
  boolean()
  ```
  
  Default value: `false`  
  

- `wait_rai?`  

  ```
  boolean()
  ```
  
  Default value: `true`  
  If true, first packet buffer is going to be a keyframe (in case of video)

- `drop_until_video_rai?`  

  ```
  boolean()
  ```
  
  Default value: `false`  
  If true, drop all non-video buffers until the first video buffer (RAI) arrives

## Pads

### `:input`

Accepted formats:
```
%Membrane.RemoteStream{}
```

Direction: | `:input`
Availability: | `:always`
Flow control: | `:auto`

### `:output`

Accepted formats:
```
Membrane.RemoteStream
```
```
Membrane.H264
```

Direction: | `:output`
Availability: | `:on_request`
Flow control: | `:auto`
Pad options:

- `pid`  

  ```
  pos_integer() | nil
  ```
  
  Default value: `nil`  
  The PID of the target stream. If specified, all other selection options are ignored

- `stream_type`  

  ```
  atom() | nil
  ```
  
  Default value: `nil`  
  More generic selector than pid, allows to specify the stream type of the target stream, e.g. AAC_ADTS.
  The first stream that matches the selector will be returned.

- `profile`  

  ```
  atom() | nil
  ```
  
  Default value: `nil`  
  Well-known stream profile (e.g. :opus_mpeg_ts, :scte35).

- `registration_descriptor`  

  ```
  String.t() | nil
  ```
  
  Default value: `nil`  
  Matches a registration descriptor (tag 0x05) format identifier, e.g. "Opus".

- `stream_category`  

  ```
  atom() | nil
  ```
  
  Default value: `nil`  
  Even more generic, select either :video, :audio, :subtitles, :cues, :metadata target streams.
  The first stream that matches the selector will be returned.

# `output_pad_opts`

```elixir
@type output_pad_opts() :: [
  pid: pos_integer() | nil,
  stream_type: atom() | nil,
  profile: atom() | nil,
  registration_descriptor: String.t() | nil,
  stream_category: atom() | nil
]
```

Options for pad `:output`

# `t`

```elixir
@type t() :: %Membrane.MPEG.TS.Demuxer{
  drop_until_video_rai?: boolean(),
  strict?: boolean(),
  wait_rai?: boolean()
}
```

Struct containing options for `Membrane.MPEG.TS.Demuxer`

# `options`

```elixir
@spec options() :: keyword()
```

Returns description of options available for this module

---

*Consult [api-reference.md](api-reference.md) for complete listing*
