# SRT

SRT(Secure Reliable Transport)는 오픈소스 비디오 전송 프로토콜이자 기술 스택으로, 예측하기 어려운 네트워크 환경에서도 스트리밍 성능을 최적화하고 보안이 적용된 스트림과 쉬운 방화벽 통과 기능을 제공하여 열악한 네트워크 환경에서도 최상의 라이브 비디오 품질을 제공합니다. 우리는 SRT를 RTMP의 훌륭한 대안 중 하나로 보고 있으며, OvenMediaEngine은 SRT를 통해 비디오 스트리밍을 수신할 수 있습니다. SRT에 대한 자세한 정보는 [SRT 얼라이언스 웹사이트](https://www.srtalliance.org/)를 방문하십시오.

<table><thead><tr><th width="216.666748046875">Item</th><th>Description</th></tr></thead><tbody><tr><td>Container</td><td>MPEG-2 TS</td></tr><tr><td>Transport</td><td>SRT</td></tr><tr><td>Codec</td><td>H.264, H.265, AAC</td></tr><tr><td>Additional Features</td><td>Multi-track Audio</td></tr></tbody></table>

SRT는 라이브 스트림을 전송할 때 MPEG-TS 형식을 사용합니다. 이는 RTMP와 달리 다양한 코덱을 지원할 수 있음을 의미합니다. 현재 OvenMediaEngine은 SRT를 통해 H.264, H.265 및 AAC 코덱을 지원합니다.

## Configuration

### Bind

SRT 리스닝 포트는 다음과 같이 설정합니다.

```xml
<!-- /Server/Bind -->
<Providers>
    ...
    <SRT>
        <Port>9998,9999</Port>
        <WorkerCount>1</WorkerCount>
        <ThreadPerSocket>true</ThreadPerSocket>
        
        <StreamMap>
            <Stream>
                <Port>9999</Port>
                <StreamPath>default/app/stream</StreamPath>
            </Stream>
        </StreamMap>
    </SRT>
    ...
</Providers>
```

<table><thead><tr><th width="217.5555419921875">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>Port</code></td><td>SRT 연결을 수신할 포트를 지정합니다. 콤마로 구분하여 여러 포트를 동시에 바인딩할 수 있습니다.</td></tr><tr><td><p><code>WorkerCount</code></p><ul><li>Default : 1</li></ul></td><td>SRT 소켓 처리를 위한 워커 스레드 수를 정의합니다. 세션 수가 많아질 경우 값을 증가시키면 트래픽을 효율적으로 분산할 수 있습니다.</td></tr><tr><td><p><code>ThreadPerSocket</code></p><ul><li>Default : false</li></ul></td><td>각 소켓에 대해 전용 스레드를 사용할지 여부를 결정합니다. true로 설정하면 각 세션마다 새로운 스레드가 생성되고 종료 시 함께 종료되며, 이 경우 <code>WorkerCount</code>는 무시됩니다.</td></tr><tr><td><code>StreamMap</code></td><td><code>streamid</code>를 지원하지 않는 인코더를 위한 매핑 기능을 제공합니다. 특정 포트로 <code>streamid</code> 없이 연결이 들어올 경우, 해당 포트를 지정된 <code>StreamPath</code>로 직접 매핑합니다.</td></tr></tbody></table>

{% hint style="warning" %}
`ThreadPerSocket`을 사용하면 AdmissionWebhooks 처리 중 Control Server 응답을 기다리는 동안 특정 세션이 블로킹되어 다른 세션이 지연되는 문제를 방지할 수 있습니다. 하지만 세션 수가 많아질 경우 스레드 컨텍스트 스위칭 오버헤드가 크게 증가할 수 있습니다. 실제 16코어 시스템 기준으로 약 100개 세션까지는 문제없이 동작하는 사례가 있습니다.
{% endhint %}

### Application

SRT 입력은 각 애플리케이션 단위로 활성화하거나 비활성화할 수 있습니다. 아래 설정은 해당 애플리케이션에서 SRT 입력 기능을 활성화합니다.

```xml
<!-- /Server/VirtualHosts/VirtualHost/Applications/Application -->
<Providers>
    ...
    <SRT />
    ...
</Providers>
```

## Encoders and `streamid`

FFmpeg, OBS Studio, srt-live-transmit 등 다양한 인코더가 SRT를 지원합니다. 각 인코더에서 SRT를 통해 스트림을 전송하는 방법은 해당 인코더의 문서를 참고해야 합니다. 여기서는 OBS Studio를 예로 설명합니다.

OvenMediaEngine은 SRT의 `streamid`를 사용하여 각 스트림을 구분합니다. 이는 MPEG-TS/UDP와 달리 하나의 포트에서 여러 개의 SRT 스트림을 수신할 수 있음을 의미합니다. `streamid`에 대한 자세한 내용은 [Haivision 공식 문서](https://github.com/Haivision/srt/blob/master/docs/features/access-control.md)를 참고하시기 바랍니다.

따라서 SRT 인코더가 OvenMediaEngine으로 스트림을 전송하려면 `streamid`에 다음 정보가 포함되어야 합니다.

> `streamid` = `{Virtual Host Name}/{App Name}/{Stream Name}`

### OBS Studio

OBS Studio 25.0 이상 버전은 SRT를 지원합니다. 자세한 내용은 [OBS 공식 문서](https://obsproject.com/wiki/Streaming-With-SRT-Protocol)를 참고하시기 바랍니다. OvenMediaEngine 주소는 OBS Studio의 Server 항목에 다음과 같이 입력합니다. SRT를 사용할 경우 Stream Key는 비워 둡니다.

`srt://{OvenMediaEngine Host}:{SRT Port}?streamid={streamid}`

<figure><img src="/files/8TmRRuAZV5KXBDQI9UkM" alt=""><figcaption></figcaption></figure>

### Blackmagic Web Presenter

Blackmagic Web Presenter, ATEM Mini Pro 또는 유사 장비에서 SRT로 OvenMediaEngine에 스트리밍하려면 "Custom URL H264/H265" 플랫폼 옵션을 선택하고 다음과 같은 형식을 사용합니다.

```
Server: srt://{OvenMediaEngine Host}:{SRT Port}
Key: {streamid}
```

## Multiple Audio Track

SRT Provider는 여러 개의 오디오 트랙 입력을 지원합니다. 이 기능은 LLHLS Publisher에 자동으로 적용됩니다.

입력 오디오 트랙에 라벨을 지정하려면 다음과 같이 설정할 수 있습니다. 이 설정은 LLHLS 재생 시 플레이어의 오디오 선택 UI에 영향을 줍니다.

```xml
<!-- /Server/VirtualHosts/VirtualHost/Applications/Application -->
<Providers>
    ...
    <SRT>
        <AudioMap>
            <Item>
                <Name>English</Name> 
                <Language>en</Language> <!-- Optioanl, RFC 5646 -->
                <Characteristics>public.accessibility.describes-video</Characteristics> <!-- Optional -->
            </Item>
            <Item>
                <Name>Korean</Name>
                <Language>ko</Language> <!-- Optioanl, RFC 5646 -->
                <Characteristics>public.alternate</Characteristics> <!-- Optional -->
            </Item>
            <Item>
                <Name>Japanese</Name>
                <Language>ja</Language> <!-- Optioanl, RFC 5646 -->
                <Characteristics>public.alternate</Characteristics> <!-- Optional -->
            </Item>
        </AudioMap>
        ...
    </SRT>
</Providers>
```

## SRT Socket Options

`<Options>`를 사용하여 OvenMediaEngine 서버의 SRT 소켓 옵션을 설정할 수 있습니다. 이는 특히 SRT 암호화 설정에 유용하며, 다음과 같이 패스프레이즈를 지정할 수 있습니다.

```xml
<!-- /Server/Bind -->
<Providers>
    ...
    <SRT>
        <Options>
            <Option>
                <Key>SRTO_PBKEYLEN</Key>
                <Value>16</Value>
            </Option>
            <Option>
                <Key>SRTO_PASSPHRASE</Key>
                <Value>thisismypassphrase</Value>
            </Option>
        </Options>
        ...
    </SRT>
</Providers>
```

SRT 소켓 옵션에 대한 자세한 내용은 다음 문서를 참고하시기 바랍니다.

* <https://github.com/Haivision/srt/blob/v1.5.2/docs/API/API-socket-options.md#list-of-options>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ovenmediaengine-enterprise.gitbook.io/guide/ko-kr/features/live-source/srt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
