Transcoding

OutputProfile

<OutputProfile> 설정을 사용하면 <Encodes> 설정을 통해 입력 스트림을 다시 인코딩하여 새로운 출력 스트림을 생성할 수 있습니다. 생성되는 출력 스트림의 이름은 <OutputStreamName> 규칙에 따라 결정되며, 생성된 스트림은 스트리밍 URL 형식에 따라 사용할 수 있습니다.

<OutputProfiles>
    <!-- 
    Common setting for decoders. Decodes is optional.

    <Decodes>
	Number of threads for the decoder.
	<ThreadCount>2</ThreadCount>

	By default, OME decodes all video frames. If OnlyKeyframes is true, only the keyframes will be decoded, massively improving thumbnail performance at the cost of having less control over when exactly they are generated
	<OnlyKeyframes>false</OnlyKeyframes>
    </Decodes>
    -->

    <OutputProfile>
        <Name>bypass_stream</Name>
        <OutputStreamName>${OriginStreamName}_bypass</OutputStreamName>
        <Encodes>
            <Video>
                <Bypass>true</Bypass>
            </Video>
            <Audio>
                <Name>aac_audio</Name>
                <Codec>aac</Codec>
                <Bitrate>128000</Bitrate>
                <Samplerate>48000</Samplerate>
                <Channel>2</Channel>
                <BypassIfMatch>
                    <Codec>eq</Codec>
                </BypassIfMatch>
            </Audio>
            <Audio>
                <Name>opus_audio</Name>
                <Codec>opus</Codec>
                <Bitrate>128000</Bitrate>
                <Samplerate>48000</Samplerate>
                <Channel>2</Channel>
                <BypassIfMatch>
                    <Codec>eq</Codec>
                </BypassIfMatch>
            </Audio>
        </Encodes>
    </OutputProfile>
</OutputProfiles>

위 설정에 따르면 입력 스트림 이름이 stream일 경우 출력 스트림은 stream_bypass가 되며, 다음과 같은 URL로 사용할 수 있습니다.

  • WebRTC ws://192.168.0.1:3333/app/stream_bypass

  • LLHLS http://192.168.0.1:8080/app/stream_bypass/llhls.m3u8

  • HLS http://192.168.0.1:8080/app/stream_bypass/ts:playlist.m3u8

Encodes

Video

비디오 인코딩 프로파일은 다음과 같이 설정할 수 있습니다.

Property
Description

Codec*

인코딩할 코덱 타입 아래 표 참조

Bitrate*

초당 비트 수

Name*

Rendition에 사용할 인코딩 이름 (중복 불가)

Width

해상도의 가로 크기

Height

해상도의 세로 크기

Framerate

초당 프레임 수

KeyFrameInterval

키프레임 간 프레임 수 (0~600, 기본값은 프레임레이트)

BFrames

B-프레임 수 (0~16, 기본값 0)

Profile

H.264 전용 프로파일 (baseline, main, high)

Preset

인코딩 품질 및 성능 프리셋

아래 표 참조

ThreadCount

인코딩 스레드 수

Lookahead

미리 분석할 프레임 수 default is 0 x264 is 0-250

nvenc is 0-31 xma is 0-20

Modules

사용할 인코더 라이브러리. 미 지정 시 기본 코덱 사용

아래 표 참조

* 필수값

Supported Video Codecs

Type
Description
Codec
Modules

Video

VP8

vp8

SW: libvpx*

H.264

h264

SW: openh264*, x264

HW: nv, xma

H.265 (Hardware Only)

h265

HW: nv, xma

Preset

각 코덱 라이브러리에서 제공하는 프리셋은 OvenMediaEngine 프리셋으로 매핑됩니다. Slow 프리셋은 높은 품질과 높은 리소스를 사용하며, Fast 프리셋은 낮은 품질과 높은 성능을 제공합니다. 시스템 환경과 서비스 목적에 따라 적절히 선택해야 합니다.

Presets
openh264
h264_nvenc
vp8

slower

QP( 10-39)

p7

best

slow

QP (16-45)

p6

best

medium

QP (24-51)

p5

good

fast

QP (32-51)

p4

realtime

faster

QP (40-51)

p3

realtime

References

  • https://trac.ffmpeg.org/wiki/Encode/VP8

  • https://docs.nvidia.com/video-technologies/video-codec-sdk/nvenc-preset-migration-guide/

Audio

오디오 인코딩 프로파일은 다음과 같이 설정할 수 있습니다.

Property
Description

Codec*

인코딩할 코덱 타입 아래 표 참조

Bitrate*

초당 비트 수

Name*

Rendition 이름 (중복 불가)

Samplerate

샘플링 레이트

Channel

오디오 채널 수

Modules

사용할 인코더 라이브러리. 미 지정 시 기본 코덱 사용

아래 표 참조

* 필수값

비디오 설정 없이 오디오만 지정하면 오디오 전용 OutputProfile도 생성할 수 있습니다.

Supported Audio Codecs

Type
Description
Codec
Modules

Audio

AAC

aac

SW: fdkaac*

Opus

opus

SW: libopus*

Bypass (Passthrough)

Video와 Audio를 다음과 같이 설정하면 트랜스코딩 없이 그대로 전달할 수 있습니다.

circle-exclamation

또한 WebRTC는 AAC를 지원하지 않기 때문에, 비디오를 bypass하는 경우에도 오디오는 Opus로 인코딩해야 합니다.

Additional Features

Conditional Encoding

입력 스트림의 코덱 또는 품질이 출력 프로파일과 동일한 경우, 불필요한 트랜스코딩을 수행하지 않도록 설정할 수 있습니다. 이는 시스템 리소스 낭비를 줄이기 위한 기능입니다. BypassIfMatch 조건이 모두 만족되면 해당 트랙은 인코딩 없이 Pass-through 됩니다.

Matching elements in video

Elements
Condition
Description

Codec (Optional)

eq

코덱 비교

Width (Optional)

eq, lte, gte

가로 해상도 비교

Height (Optional)

eq, lte, gte

세로 해상도 비교

SAR (Optional)

eq

화면 비율 비교

* eq: equal to / lte: less than or equal to / gte: greater than or equal to

Matching elements in audio

Elements
Condition
Description

Codec (Optional)

eq

코덱 비교

Samplerate (Optional)

eq, lte, gte

샘플링 레이트 비교

Channel (Optional)

eq, lte, gte

채널 수 비교

* eq: equal to / lte: less than or equal to / gte: greater than or equal to

WebRTC 및 LLHLS를 지원하려면 AAC 및 Opus 코덱을 동시에 지원해야 합니다. 불필요한 오디오 인코딩을 줄이려면 아래 설정을 사용하십시오.

인코딩 옵션보다 낮은 화질의 비디오 트랙이 입력될 경우, 불필요한 업스케일링을 방지할 수 있습니다. SAR(저장 화면비)은 원본 픽셀의 비율입니다. 아래 예시에서, 원본 비디오의 가로세로가 인코딩 옵션에 설정된 가로세로보다 작거나 같더라도, 비율이 다르면 바이패스 없이 인코딩이 진행됩니다.

Keep Original and Change Bitrate

원본과 동일한 품질을 유지하면서 트랜스코딩하려면 Width, Height, Framerate, Samplerate, Channel 값을 생략하면 됩니다. 이 경우 원본과 동일한 설정으로 인코딩됩니다.

Rescaling with Keep the Aspect Ratio

트랜스코딩 시 비디오 해상도를 변경하려면 비디오 인코딩 옵션에서 너비와 높이 값을 사용하십시오. 원본 해상도를 모르는 경우 트랜스코딩 후 화면 비율을 유지하기 어려울 수 있습니다. 이러한 문제를 해결하려면 다음 방법을 사용하십시오. 예를 들어, 비디오 인코딩 옵션에서 너비 값만 입력하면 높이 값은 원본 비디오의 비율에 따라 자동으로 생성됩니다.

Decoding Thread Configuration

소프트웨어 디코더는 기본적으로 2개의 스레드를 사용합니다. CPU 성능이 부족할 경우 스레드 수를 늘려 성능을 향상시킬 수 있습니다.

Last updated