Skip to content

Commit 5efd3fd

Browse files
committed
Share encoders.
1 parent 954b422 commit 5efd3fd

File tree

12 files changed

+337
-341
lines changed

12 files changed

+337
-341
lines changed

scripts/transcoder/20-prometheus.liq

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,21 @@
1919
is_ready_metric_create =
2020
prometheus.gauge(
2121
labels=["radio", "type", "name"],
22-
help=
23-
"Is source ready?",
22+
help="Is source ready?",
2423
"liquidsoap_source_is_ready"
2524
)
2625

2726
duration_unready_seconds_metric_create =
2827
prometheus.counter(
2928
labels=["radio", "type", "name"],
30-
help=
31-
"Cumulative duration in seconds of the source in unready state",
29+
help="Cumulative duration in seconds of the source in unready state",
3230
"liquidsoap_source_unready_duration_seconds"
3331
)
3432

3533
is_preferred_livesource_metric =
3634
prometheus.gauge(
3735
labels=["radio", "type", "name"],
38-
help=
39-
"Is source the preferred livesource?",
36+
help="Is source the preferred livesource?",
4037
"liquidsoap_source_is_preferred_livesource"
4138
)
4239

@@ -75,8 +72,7 @@ end
7572
create_is_playing_metric =
7673
prometheus.gauge(
7774
labels=["radio", "type", "name"],
78-
help=
79-
"Is source playing?",
75+
help="Is source playing?",
8076
"liquidsoap_source_is_playing"
8177
)
8278

@@ -86,8 +82,7 @@ create_is_playing_metric =
8682
is_blank_metric_create =
8783
prometheus.gauge(
8884
labels=["radio", "type", "name"],
89-
help=
90-
"Is source blank?",
85+
help="Is source blank?",
9186
"liquidsoap_source_is_blank"
9287
)
9388

@@ -96,8 +91,7 @@ is_blank_metric_create =
9691
audit_lufs_metric_create =
9792
prometheus.gauge(
9893
labels=["radio", "type", "name"],
99-
help=
100-
"Audio LUFS Analysis",
94+
help="Audio LUFS Analysis",
10195
"liquidsoap_output_lufs_5s"
10296
)
10397

@@ -114,47 +108,41 @@ audit_lufs_metric_create =
114108
srt_input_bytes_available_create =
115109
prometheus.gauge(
116110
labels=["radio", "type", "name"],
117-
help=
118-
"SRT stat byteAvailRcvBuf",
111+
help="SRT stat byteAvailRcvBuf",
119112
"liquidsoap_srt_input_bytes_available"
120113
)
121114

122115
srt_input_packet_received_buffer_create =
123116
prometheus.gauge(
124117
labels=["radio", "type", "name"],
125-
help=
126-
"SRT stat pktRcvBuf",
118+
help="SRT stat pktRcvBuf",
127119
"liquidsoap_srt_input_packet_received_buffer"
128120
)
129121

130122
srt_input_packet_received_create =
131123
prometheus.gauge(
132124
labels=["radio", "type", "name"],
133-
help=
134-
"SRT stat pktRecvTotal (cumulative)",
125+
help="SRT stat pktRecvTotal (cumulative)",
135126
"liquidsoap_srt_input_packet_received_total"
136127
)
137128

138129
srt_input_packet_drop_create =
139130
prometheus.gauge(
140131
labels=["radio", "type", "name"],
141-
help=
142-
"SRT stat pktRcvDropTotal (cumulative)",
132+
help="SRT stat pktRcvDropTotal (cumulative)",
143133
"liquidsoap_srt_input_packet_drop_total"
144134
)
145135

146136
srt_input_packet_loss_create =
147137
prometheus.gauge(
148138
labels=["radio", "type", "name"],
149-
help=
150-
"SRT stat pktRcvLossTotal (cumulative)",
139+
help="SRT stat pktRcvLossTotal (cumulative)",
151140
"liquidsoap_srt_input_packet_loss_total"
152141
)
153142

154143
srt_input_buffer_length_create =
155144
prometheus.gauge(
156145
labels=["radio", "type", "name"],
157-
help=
158-
"Length of the SRT buffer",
146+
help="Length of the SRT buffer",
159147
"liquidsoap_srt_input_buffer_length"
160148
)

scripts/transcoder/30-formats.liq

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
let formats = {surround={icecast=(), hls=()}, stereo={icecast=(), hls=()}}
1+
let formats = {surround=(), stereo=()}
22

3-
%include "formats/hls.aac.liq"
4-
%include "formats/hls.libfdk_aac.liq"
5-
%include "formats/icecast.aac.liq"
6-
%include "formats/icecast.libfdk_aac.liq"
7-
%include "formats/icecast.mp3.liq"
3+
%include "formats/aac.liq"
4+
%include "formats/libfdk_aac.liq"
5+
%include "formats/mp3.liq"
86

97
formats = formats_picker(formats)

scripts/transcoder/80-outputs.liq

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,96 @@
11
# Outputs
22

3+
aac_formats = list.assoc(default=[], "aac", icecast_formats)
4+
aac_formats =
5+
list.fold(
6+
fun (aac_formats, format) ->
7+
if
8+
list.mem(format, aac_formats)
9+
then
10+
aac_formats
11+
else
12+
[format, ...aac_formats]
13+
end,
14+
aac_formats,
15+
hls_formats
16+
)
17+
18+
aac_encoders =
19+
if aac_encoder == "aac" then formats.aac else formats.libfdk_aac end
20+
21+
aac_encoders =
22+
list.map(
23+
fun (name) ->
24+
begin
25+
enc = list.assoc(name, aac_encoders)
26+
(
27+
name,
28+
ffmpeg.encode.audio(id="radio-prod-aac-#{name}", enc, radio_prod)
29+
)
30+
end,
31+
aac_formats
32+
)
33+
34+
mp3_encoders =
35+
list.map(
36+
fun (name) ->
37+
begin
38+
enc = list.assoc(name, formats.mp3)
39+
(
40+
name,
41+
ffmpeg.encode.audio(id="radio-prod-mp3-#{name}", enc, radio_prod)
42+
)
43+
end,
44+
list.assoc(default=[], "mp3", icecast_formats)
45+
)
46+
347
# HLS Output
448
if
549
hls_formats != []
650
then
751
%include "outputs/hls.liq"
8-
mk_hls_output(hls_formats, radio_prod)
52+
hls_encoders =
53+
list.map(fun (name) -> (name, list.assoc(name, aac_encoders)), hls_formats)
54+
55+
mk_hls_output(hls_encoders)
956
end
1057

1158
# Icecast Output
1259
if
1360
icecast_formats != []
1461
then
1562
%include "outputs/icecast.liq"
16-
mk_icecast_outputs(icecast_formats, radio_prod)
63+
icecast_encoders =
64+
[
65+
(
66+
"mp3",
67+
list.map(
68+
fun (name) ->
69+
(
70+
name,
71+
{
72+
encoded_stream=list.assoc(name, mp3_encoders),
73+
file_extension=".mp3"
74+
}
75+
),
76+
list.assoc(default=[], "mp3", icecast_formats)
77+
)
78+
),
79+
(
80+
"aac",
81+
list.map(
82+
fun (name) ->
83+
(
84+
name,
85+
{
86+
encoded_stream=list.assoc(name, aac_encoders),
87+
file_extension=".aac"
88+
}
89+
),
90+
list.assoc(default=[], "aac", icecast_formats)
91+
)
92+
)
93+
]
94+
95+
mk_icecast_outputs(icecast_encoders)
1796
end

scripts/transcoder/90-http.liq

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,20 @@ def post_livesource(req, res) =
4242
end
4343

4444
harbor.http.register(
45-
port=harbor_http_port, method="GET", "/readiness", get_readiness
45+
port=harbor_http_port,
46+
method="GET",
47+
"/readiness",
48+
get_readiness
4649
)
4750
harbor.http.register(
48-
port=harbor_http_port, method="GET", "/livesource", get_livesource
51+
port=harbor_http_port,
52+
method="GET",
53+
"/livesource",
54+
get_livesource
4955
)
5056
harbor.http.register(
51-
port=harbor_http_port, method="POST", "/livesource", post_livesource
57+
port=harbor_http_port,
58+
method="POST",
59+
"/livesource",
60+
post_livesource
5261
)

scripts/transcoder/formats/hls.aac.liq renamed to scripts/transcoder/formats/aac.liq

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
let formats.stereo.hls.aac =
1+
let formats.stereo.aac =
22
[
33
(
44
"lofi",
5-
6-
# See: https://github.com/savonet/liquidsoap/pull/4401
75
%ffmpeg(
8-
format = "mpegts",
9-
interleaved = false,
106
%audio(
117
codec = "aac",
128
channels = 2,
@@ -19,8 +15,6 @@ let formats.stereo.hls.aac =
1915
(
2016
"midfi",
2117
%ffmpeg(
22-
format = "mpegts",
23-
interleaved = false,
2418
%audio(
2519
codec = "aac",
2620
channels = 2,
@@ -33,8 +27,6 @@ let formats.stereo.hls.aac =
3327
(
3428
"hifi",
3529
%ffmpeg(
36-
format = "mpegts",
37-
interleaved = false,
3830
%audio(
3931
codec = "aac",
4032
channels = 2,
@@ -47,8 +39,6 @@ let formats.stereo.hls.aac =
4739
(
4840
"insane",
4941
%ffmpeg(
50-
format = "mpegts",
51-
interleaved = false,
5242
%audio(
5343
codec = "aac",
5444
channels = 2,
@@ -60,27 +50,23 @@ let formats.stereo.hls.aac =
6050
)
6151
]
6252

63-
let formats.surround.hls.aac =
53+
let formats.surround.aac =
6454
[
6555
(
6656
"hifi",
6757
%ffmpeg(
68-
format = "mpegts",
69-
interleaved = false,
7058
%audio(
7159
codec = "aac",
7260
channel_layout = 5.1,
7361
b = "192k",
7462
samplerate = 48000,
75-
profile = "aac_low"
63+
profile = "aac_he"
7664
)
7765
)
7866
),
7967
(
8068
"insane",
8169
%ffmpeg(
82-
format = "mpegts",
83-
interleaved = false,
8470
%audio(
8571
codec = "aac",
8672
channel_layout = 5.1,

0 commit comments

Comments
 (0)