Skip to content

Commit 3d12e11

Browse files
committed
add e-rtmp to ts-sdk
1 parent 843d3eb commit 3d12e11

5 files changed

Lines changed: 144 additions & 20 deletions

File tree

smelter-api/src/output/rtmp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub enum RtmpClientVideoEncoderOptions {
5454
#[serde(rename = "ffmpeg_vp8")]
5555
FfmpegVp8 {
5656
/// Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate.
57+
/// For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
5758
bitrate: Option<VideoEncoderBitrate>,
5859

5960
/// (**default=`5000`**) Maximal interval between keyframes, in milliseconds.
@@ -66,6 +67,7 @@ pub enum RtmpClientVideoEncoderOptions {
6667
#[serde(rename = "ffmpeg_vp9")]
6768
FfmpegVp9 {
6869
/// Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate.
70+
/// For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
6971
bitrate: Option<VideoEncoderBitrate>,
7072

7173
/// (**default=`5000`**) Maximal interval between keyframes, in milliseconds.

tools/schemas/openapi_specification.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/smelter-core/src/api/output/rtmp.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ function intoRtmpClientVideoEncoderOptions(
4646
pixel_format: encoder.pixelFormat,
4747
ffmpeg_options: encoder.ffmpegOptions,
4848
};
49+
case 'ffmpeg_vp8':
50+
return {
51+
type: 'ffmpeg_vp8',
52+
bitrate: encoder.bitrate && intoVideoEncoderBitrate(encoder.bitrate),
53+
keyframe_interval_ms: encoder.keyframeIntervalMs,
54+
ffmpeg_options: encoder.ffmpegOptions,
55+
};
56+
case 'ffmpeg_vp9':
57+
return {
58+
type: 'ffmpeg_vp9',
59+
bitrate: encoder.bitrate && intoVideoEncoderBitrate(encoder.bitrate),
60+
keyframe_interval_ms: encoder.keyframeIntervalMs,
61+
pixel_format: encoder.pixelFormat,
62+
ffmpeg_options: encoder.ffmpegOptions,
63+
};
4964
case 'vulkan_h264':
5065
return {
5166
type: 'vulkan_h264',
@@ -70,8 +85,17 @@ function intoOutputRtmpClientAudioOptions(
7085
function intoRtmpClientAudioEncoderOptions(
7186
encoder: Outputs.RtmpClientAudioEncoderOptions
7287
): Api.RtmpClientAudioEncoderOptions {
73-
return {
74-
type: 'aac',
75-
sample_rate: encoder.sampleRate,
76-
};
88+
switch (encoder.type) {
89+
case 'aac':
90+
return {
91+
type: 'aac',
92+
sample_rate: encoder.sampleRate,
93+
};
94+
case 'opus':
95+
return {
96+
type: 'opus',
97+
preset: encoder.preset,
98+
sample_rate: encoder.sampleRate,
99+
};
100+
}
77101
}

ts/smelter/src/api.generated.ts

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,44 @@ export type RtmpClientVideoEncoderOptions =
997997
[k: string]: string;
998998
} | null;
999999
}
1000+
| {
1001+
type: "ffmpeg_vp8";
1002+
/**
1003+
* Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate. For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
1004+
*/
1005+
bitrate?: VideoEncoderBitrate | null;
1006+
/**
1007+
* (**default=`5000`**) Maximal interval between keyframes, in milliseconds.
1008+
*/
1009+
keyframe_interval_ms?: number | null;
1010+
/**
1011+
* Raw FFmpeg encoder options. See [docs](https://ffmpeg.org/ffmpeg-codecs.html) for more.
1012+
*/
1013+
ffmpeg_options?: {
1014+
[k: string]: string;
1015+
} | null;
1016+
}
1017+
| {
1018+
type: "ffmpeg_vp9";
1019+
/**
1020+
* Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate. For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
1021+
*/
1022+
bitrate?: VideoEncoderBitrate | null;
1023+
/**
1024+
* (**default=`5000`**) Maximal interval between keyframes, in milliseconds.
1025+
*/
1026+
keyframe_interval_ms?: number | null;
1027+
/**
1028+
* (**default=`"yuv420p"`**) Encoder pixel format.
1029+
*/
1030+
pixel_format?: PixelFormat | null;
1031+
/**
1032+
* Raw FFmpeg encoder options. See [docs](https://ffmpeg.org/ffmpeg-codecs.html) for more.
1033+
*/
1034+
ffmpeg_options?: {
1035+
[k: string]: string;
1036+
} | null;
1037+
}
10001038
| {
10011039
type: "vulkan_h264";
10021040
/**
@@ -1008,13 +1046,25 @@ export type RtmpClientVideoEncoderOptions =
10081046
*/
10091047
keyframe_interval_ms?: number | null;
10101048
};
1011-
export type RtmpClientAudioEncoderOptions = {
1012-
type: "aac";
1013-
/**
1014-
* (**default=`48000`**) Sample rate. Allowed values: [8000, 16000, 24000, 44100, 48000].
1015-
*/
1016-
sample_rate?: number | null;
1017-
};
1049+
export type RtmpClientAudioEncoderOptions =
1050+
| {
1051+
type: "aac";
1052+
/**
1053+
* (**default=`44100`**) Sample rate. Allowed values: [8000, 16000, 24000, 44100, 48000].
1054+
*/
1055+
sample_rate?: number | null;
1056+
}
1057+
| {
1058+
type: "opus";
1059+
/**
1060+
* (**default=`"voip"`**) Audio output encoder preset.
1061+
*/
1062+
preset?: OpusEncoderPreset | null;
1063+
/**
1064+
* (**default=`48000`**) Sample rate. Allowed values: [8000, 16000, 24000, 48000].
1065+
*/
1066+
sample_rate?: number | null;
1067+
};
10181068
export type Mp4VideoEncoderOptions =
10191069
| {
10201070
type: "ffmpeg_h264";

ts/smelter/src/types/output/rtmp.ts

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,42 @@ export type RtmpClientVideoEncoderOptions =
4040
*/
4141
ffmpegOptions?: Record<string, string>;
4242
}
43+
| {
44+
type: 'ffmpeg_vp8';
45+
/**
46+
* Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate.
47+
* For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
48+
*/
49+
bitrate?: VideoEncoderBitrate;
50+
/**
51+
* (**default=`5000`**) Maximal interval between keyframes, in milliseconds.
52+
*/
53+
keyframeIntervalMs?: number;
54+
/**
55+
* Raw FFmpeg encoder options. See [docs](https://ffmpeg.org/ffmpeg-codecs.html) for more.
56+
*/
57+
ffmpegOptions?: Record<string, string>;
58+
}
59+
| {
60+
type: 'ffmpeg_vp9';
61+
/**
62+
* Encoding bitrate. If not provided, bitrate is calculated based on resolution and framerate.
63+
* For example at 1080p 30 FPS the average bitrate is 5000 kbit/s and max bitrate is 6250 kbit/s.
64+
*/
65+
bitrate?: VideoEncoderBitrate;
66+
/**
67+
* (**default=`5000`**) Maximal interval between keyframes, in milliseconds.
68+
*/
69+
keyframeIntervalMs?: number;
70+
/**
71+
* (**default=`"yuv420p"`**) Encoder pixel format
72+
*/
73+
pixelFormat?: Api.PixelFormat;
74+
/**
75+
* Raw FFmpeg encoder options. See [docs](https://ffmpeg.org/ffmpeg-codecs.html) for more.
76+
*/
77+
ffmpegOptions?: Record<string, string>;
78+
}
4379
| {
4480
type: 'vulkan_h264';
4581
/**
@@ -72,10 +108,22 @@ export type RtmpClientAudioOptions = {
72108
encoder: RtmpClientAudioEncoderOptions;
73109
};
74110

75-
export type RtmpClientAudioEncoderOptions = {
76-
type: 'aac';
77-
/**
78-
* (**default=`48000`**) Sample rate. Allowed values: [8000, 16000, 24000, 44100, 48000].
79-
*/
80-
sampleRate?: number;
81-
};
111+
export type RtmpClientAudioEncoderOptions =
112+
| {
113+
type: 'aac';
114+
/**
115+
* (**default=`44100`**) Sample rate. Allowed values: [8000, 16000, 24000, 44100, 48000].
116+
*/
117+
sampleRate?: number;
118+
}
119+
| {
120+
type: 'opus';
121+
/**
122+
* (**default=`"voip"`**) Audio output encoder preset.
123+
*/
124+
preset?: Api.OpusEncoderPreset;
125+
/**
126+
* (**default=`48000`**) Sample rate. Allowed values: [8000, 16000, 24000, 48000].
127+
*/
128+
sampleRate?: number;
129+
};

0 commit comments

Comments
 (0)