codemirror-lang-liquidsoap 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +13 -13
- package/dist/index.js +15 -13
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/liquidsoap.grammar +9 -1
- package/src/parser.js +8 -8
- package/src/parser.terms.js +6 -5
- package/tests/liquidsoap/.github/scripts/build-posix.sh +0 -3
- package/tests/liquidsoap/.github/workflows/ci.yml +35 -10
- package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
- package/tests/liquidsoap/CHANGES.md +1 -0
- package/tests/liquidsoap/CITATION.cff +17 -0
- package/tests/liquidsoap/doc/Makefile +17 -0
- package/tests/liquidsoap/doc/content/beets.md +6 -47
- package/tests/liquidsoap/doc/content/blank.md +5 -17
- package/tests/liquidsoap/doc/content/complete_case.md +1 -53
- package/tests/liquidsoap/doc/content/cookbook.md +23 -170
- package/tests/liquidsoap/doc/content/crossfade.md +1 -73
- package/tests/liquidsoap/doc/content/dynamic_sources.md +1 -47
- package/tests/liquidsoap/doc/content/external_decoders.md +6 -118
- package/tests/liquidsoap/doc/content/external_encoders.md +2 -4
- package/tests/liquidsoap/doc/content/external_streams.md +6 -20
- package/tests/liquidsoap/doc/content/ffmpeg_cookbook.md +9 -147
- package/tests/liquidsoap/doc/content/ffmpeg_filters.md +6 -93
- package/tests/liquidsoap/doc/content/harbor.md +4 -40
- package/tests/liquidsoap/doc/content/harbor_http.md +10 -118
- package/tests/liquidsoap/doc/content/help.md +1 -9
- package/tests/liquidsoap/doc/content/hls_output.md +6 -102
- package/tests/liquidsoap/doc/content/http_input.md +2 -4
- package/tests/liquidsoap/doc/content/icy_metadata.md +2 -24
- package/tests/liquidsoap/doc/content/in_production.md +2 -7
- package/tests/liquidsoap/doc/content/json.md +10 -36
- package/tests/liquidsoap/doc/content/language.md +1 -1
- package/tests/liquidsoap/doc/content/liq/Makefile +8 -0
- package/tests/liquidsoap/doc/content/liq/append-silence.liq +46 -0
- package/tests/liquidsoap/doc/content/liq/beets-amplify.liq +29 -0
- package/tests/liquidsoap/doc/content/liq/beets-protocol.liq +26 -0
- package/tests/liquidsoap/doc/content/liq/beets-source.liq +21 -0
- package/tests/liquidsoap/doc/content/liq/blank-detect.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/blank-sorry.liq +11 -0
- package/tests/liquidsoap/doc/content/liq/check +4 -0
- package/tests/liquidsoap/doc/content/liq/complete-case.liq +69 -0
- package/tests/liquidsoap/doc/content/liq/cross.smart.liq +37 -0
- package/tests/liquidsoap/doc/content/liq/crossfade.liq +120 -0
- package/tests/liquidsoap/doc/content/liq/decoder-faad.liq +122 -0
- package/tests/liquidsoap/doc/content/liq/decoder-flac.liq +19 -0
- package/tests/liquidsoap/doc/content/liq/decoder-metaflac.liq +24 -0
- package/tests/liquidsoap/doc/content/liq/dump-hourly.liq +7 -0
- package/tests/liquidsoap/doc/content/liq/dump-hourly2.liq +4 -0
- package/tests/liquidsoap/doc/content/liq/dynamic-source.liq +55 -0
- package/tests/liquidsoap/doc/content/liq/external-output.file.liq +7 -0
- package/tests/liquidsoap/doc/content/liq/fallback.liq +4 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-dynamic-volume.liq +36 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-flanger-highpass.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip.liq +9 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip2.liq +23 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-parallel-flanger-highpass.liq +36 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-live-switch.liq +23 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-relay-ondemand.liq +31 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-relay.liq +19 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding-rtmp.liq +43 -0
- package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding.liq +28 -0
- package/tests/liquidsoap/doc/content/liq/frame-size.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/harbor-auth.liq +18 -0
- package/tests/liquidsoap/doc/content/liq/harbor-insert-metadata.liq +28 -0
- package/tests/liquidsoap/doc/content/liq/harbor-metadata.liq +14 -0
- package/tests/liquidsoap/doc/content/liq/harbor-redirect.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/harbor-simple.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/harbor-usage.liq +16 -0
- package/tests/liquidsoap/doc/content/liq/harbor.http.register.liq +48 -0
- package/tests/liquidsoap/doc/content/liq/harbor.http.response.liq +20 -0
- package/tests/liquidsoap/doc/content/liq/hls-metadata.liq +18 -0
- package/tests/liquidsoap/doc/content/liq/hls-mp4.liq +35 -0
- package/tests/liquidsoap/doc/content/liq/http-input.liq +6 -0
- package/tests/liquidsoap/doc/content/liq/icy-update.liq +31 -0
- package/tests/liquidsoap/doc/content/liq/input.mplayer.liq +26 -0
- package/tests/liquidsoap/doc/content/liq/json-ex.liq +29 -0
- package/tests/liquidsoap/doc/content/liq/json-stringify.liq +2 -0
- package/tests/liquidsoap/doc/content/liq/json1.liq +3 -0
- package/tests/liquidsoap/doc/content/liq/liquidsoap +4 -0
- package/tests/liquidsoap/doc/content/liq/live-switch.liq +23 -0
- package/tests/liquidsoap/doc/content/liq/medialib.liq +4 -0
- package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track.liq +24 -0
- package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track2.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/multitrack-default-video-track.liq +14 -0
- package/tests/liquidsoap/doc/content/liq/multitrack.liq +11 -0
- package/tests/liquidsoap/doc/content/liq/multitrack2.liq +16 -0
- package/tests/liquidsoap/doc/content/liq/multitrack3.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/output.file.hls.liq +44 -0
- package/tests/liquidsoap/doc/content/liq/prometheus-callback.liq +18 -0
- package/tests/liquidsoap/doc/content/liq/prometheus-settings.liq +3 -0
- package/tests/liquidsoap/doc/content/liq/radiopi.liq +467 -0
- package/tests/liquidsoap/doc/content/liq/re-encode.liq +14 -0
- package/tests/liquidsoap/doc/content/liq/regular.liq +8 -0
- package/tests/liquidsoap/doc/content/liq/replaygain-metadata.liq +6 -0
- package/tests/liquidsoap/doc/content/liq/replaygain-playlist.liq +6 -0
- package/tests/liquidsoap/doc/content/liq/rtmp.liq +10 -0
- package/tests/liquidsoap/doc/content/liq/samplerate3.liq +8 -0
- package/tests/liquidsoap/doc/content/liq/scheduling.liq +7 -0
- package/tests/liquidsoap/doc/content/liq/seek-telnet.liq +23 -0
- package/tests/liquidsoap/doc/content/liq/settings.liq +8 -0
- package/tests/liquidsoap/doc/content/liq/shoutcast.liq +5 -0
- package/tests/liquidsoap/doc/content/liq/space_overhead.liq +9 -0
- package/tests/liquidsoap/doc/content/liq/split-cue.liq +21 -0
- package/tests/liquidsoap/doc/content/liq/srt-receiver.liq +8 -0
- package/tests/liquidsoap/doc/content/liq/srt-sender.liq +4 -0
- package/tests/liquidsoap/doc/content/liq/transcoding.liq +18 -0
- package/tests/liquidsoap/doc/content/liq/video-anonymizer.liq +31 -0
- package/tests/liquidsoap/doc/content/liq/video-bluescreen.liq +14 -0
- package/tests/liquidsoap/doc/content/liq/video-in-video.liq +7 -0
- package/tests/liquidsoap/doc/content/liq/video-logo.liq +9 -0
- package/tests/liquidsoap/doc/content/liq/video-osc.liq +26 -0
- package/tests/liquidsoap/doc/content/liq/video-simple.liq +12 -0
- package/tests/liquidsoap/doc/content/liq/video-static.liq +20 -0
- package/tests/liquidsoap/doc/content/liq/video-text.liq +5 -0
- package/tests/liquidsoap/doc/content/liq/video-transition.liq +5 -0
- package/tests/liquidsoap/doc/content/liq/video-weather.liq +7 -0
- package/tests/liquidsoap/doc/content/liq/video-webcam.liq +1 -0
- package/tests/liquidsoap/doc/content/memory.md +2 -14
- package/tests/liquidsoap/doc/content/multitrack.md +6 -81
- package/tests/liquidsoap/doc/content/prometheus.md +8 -22
- package/tests/liquidsoap/doc/content/quick_start.md +1 -1
- package/tests/liquidsoap/doc/content/radiopi.md +1 -298
- package/tests/liquidsoap/doc/content/replay_gain.md +2 -7
- package/tests/liquidsoap/doc/content/seek.md +2 -18
- package/tests/liquidsoap/doc/content/shoutcast.md +1 -5
- package/tests/liquidsoap/doc/content/split-cue.md +1 -26
- package/tests/liquidsoap/doc/content/video-static.md +1 -20
- package/tests/liquidsoap/doc/content/video.md +23 -111
- package/tests/liquidsoap/doc/dune +6 -0
- package/tests/liquidsoap/doc/dune.inc +11350 -406
- package/tests/liquidsoap/doc/gen_dune.ml +81 -31
- package/tests/liquidsoap/doc/no-pandoc +1 -1
- package/tests/liquidsoap/liquidsoap +2 -1
- package/tests/liquidsoap/src/core/io/srt_io.ml +12 -3
- package/tests/liquidsoap/src/core/operators/video_effects.ml +3 -1
- package/tests/liquidsoap/src/core/outputs/output.ml +4 -2
- package/tests/liquidsoap/src/core/outputs/output.mli +2 -0
- package/tests/liquidsoap/src/core/visualization/video_volume.ml +7 -4
- package/tests/liquidsoap/src/js/index.html +2 -2
- package/tests/liquidsoap/src/lang/parser.mly +10 -10
- package/tests/liquidsoap/src/lang/term/parsed_term.ml +7 -11
- package/tests/liquidsoap/src/lang/term/term_reducer.ml +32 -32
- package/tests/liquidsoap/src/lang/utils.ml +3 -3
- package/tests/liquidsoap/src/libs/file.liq +15 -2
- package/tests/liquidsoap/src/libs/playlist.liq +3 -0
- package/tests/liquidsoap/src/runtime/main.ml +3 -0
- package/tests/liquidsoap/src/tooling/parsed_json.ml +9 -10
- package/tests/liquidsoap/tests/language/file.liq +4 -0
- package/tests/liquidsoap/tests/language/record.liq +33 -0
- package/tests/liquidsoap/tests/language/regexp.liq +2 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/liquidsoap
|
|
2
|
+
|
|
3
|
+
# Lines starting with # are comments, they are ignored.
|
|
4
|
+
|
|
5
|
+
# Put the log file in some directory where you have permission to write.
|
|
6
|
+
log.file.path := "/tmp/<script>.log"
|
|
7
|
+
|
|
8
|
+
# Print log messages to the console, can also be done by passing the -v option
|
|
9
|
+
# to Liquidsoap.
|
|
10
|
+
log.stdout := true
|
|
11
|
+
|
|
12
|
+
# Use the telnet server for requests
|
|
13
|
+
settings.server.telnet := true
|
|
14
|
+
|
|
15
|
+
# A bunch of files and playlists, supposedly all located in the same base dir.
|
|
16
|
+
default = single("~/radio/default.ogg")
|
|
17
|
+
|
|
18
|
+
day = playlist("~/radio/day.pls")
|
|
19
|
+
night = playlist("~/radio/night.pls")
|
|
20
|
+
jingles = playlist("~/radio/jingles.pls")
|
|
21
|
+
clock = single("~/radio/clock.ogg")
|
|
22
|
+
|
|
23
|
+
# Play user requests if there are any, otherwise one of our playlists, and the
|
|
24
|
+
# default file if anything goes wrong.
|
|
25
|
+
radio =
|
|
26
|
+
fallback(
|
|
27
|
+
[
|
|
28
|
+
request.queue(id="request"),
|
|
29
|
+
switch([({6h-22h}, day), ({22h-6h}, night)]),
|
|
30
|
+
default
|
|
31
|
+
]
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Add the normal jingles
|
|
35
|
+
radio = random(weights=[1, 5], [jingles, radio])
|
|
36
|
+
|
|
37
|
+
# And the clock jingle
|
|
38
|
+
radio = add([radio, switch([({true}, clock)])])
|
|
39
|
+
|
|
40
|
+
radio = mksafe(radio)
|
|
41
|
+
|
|
42
|
+
# Add the ability to relay live shows
|
|
43
|
+
full =
|
|
44
|
+
fallback(
|
|
45
|
+
track_sensitive=false, [input.http("http://localhost:8000/live.ogg"), radio]
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Output the full stream in OGG and MP3
|
|
49
|
+
output.icecast(
|
|
50
|
+
%mp3, host="localhost", port=8000, password="hackme", mount="radio", full
|
|
51
|
+
)
|
|
52
|
+
output.icecast(
|
|
53
|
+
%vorbis,
|
|
54
|
+
host="localhost",
|
|
55
|
+
port=8000,
|
|
56
|
+
password="hackme",
|
|
57
|
+
mount="radio.ogg",
|
|
58
|
+
full
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Output the stream without live in OGG
|
|
62
|
+
output.icecast(
|
|
63
|
+
%vorbis,
|
|
64
|
+
host="localhost",
|
|
65
|
+
port=8000,
|
|
66
|
+
password="hackme",
|
|
67
|
+
mount="radio_nolive.ogg",
|
|
68
|
+
radio
|
|
69
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
music = sine()
|
|
2
|
+
jingles = sine()
|
|
3
|
+
|
|
4
|
+
# BEGIN
|
|
5
|
+
# A function to add a source_tag metadata to a source:
|
|
6
|
+
def source_tag(s, tag) =
|
|
7
|
+
def f(_) =
|
|
8
|
+
[("source_tag", (tag : string))]
|
|
9
|
+
end
|
|
10
|
+
metadata.map(id=tag, insert_missing=true, f, s)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Tag our sources
|
|
14
|
+
music = source_tag(music, "music")
|
|
15
|
+
jingles = source_tag(jingles, "jingles")
|
|
16
|
+
|
|
17
|
+
# Combine them with one jingle every 3 music tracks
|
|
18
|
+
radio = rotate(weights=[1, 3], [jingles, music])
|
|
19
|
+
|
|
20
|
+
# Now a custom crossfade transition:
|
|
21
|
+
def transition(a, b) =
|
|
22
|
+
# If old or new source is not music, no fade
|
|
23
|
+
if
|
|
24
|
+
a.metadata["source_tag"] != "music" or a.metadata["source_tag"] != "music"
|
|
25
|
+
then
|
|
26
|
+
sequence([a.source, b.source])
|
|
27
|
+
else
|
|
28
|
+
# Else, apply the standard smart transition
|
|
29
|
+
cross.smart(a, b)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Apply it!
|
|
34
|
+
radio = cross(duration=5., transition, radio)
|
|
35
|
+
|
|
36
|
+
# END
|
|
37
|
+
output.dummy(fallible=true, radio)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Smart transition for crossfade
|
|
2
|
+
# @category Source / Fade
|
|
3
|
+
# @param ~fade_in Fade-in duration, if any.
|
|
4
|
+
# @param ~fade_out Fade-out duration, if any.
|
|
5
|
+
# @param ~high Value, in dB, for loud sound level.
|
|
6
|
+
# @param ~medium Value, in dB, for medium sound level.
|
|
7
|
+
# @param ~margin Margin to detect sources that have too different sound level for crossing.
|
|
8
|
+
# @param ~default Smart crossfade: transition used when no rule applies (default: sequence).
|
|
9
|
+
# @param a Ending track
|
|
10
|
+
# @param b Starting track
|
|
11
|
+
def cross.smart(
|
|
12
|
+
~id=null(),
|
|
13
|
+
~fade_in=3.,
|
|
14
|
+
~fade_out=3.,
|
|
15
|
+
~default=(fun (a, b) -> (sequence([a, b]) : source)),
|
|
16
|
+
~high=-15.,
|
|
17
|
+
~medium=-32.,
|
|
18
|
+
~margin=4.,
|
|
19
|
+
a,
|
|
20
|
+
b
|
|
21
|
+
) =
|
|
22
|
+
id = string.id.default(default="crossfade", id)
|
|
23
|
+
def log(~level=3, x) =
|
|
24
|
+
log(label=id, level=level, x)
|
|
25
|
+
end
|
|
26
|
+
let fade.out = fun (s) -> fade.out(type="sin", duration=fade_out, s)
|
|
27
|
+
let fade.in = fun (s) -> fade.in(type="sin", duration=fade_in, s)
|
|
28
|
+
add = fun (a, b) -> add(normalize=false, [b, a])
|
|
29
|
+
|
|
30
|
+
# This is for the type system..
|
|
31
|
+
ignore(a.metadata["foo"])
|
|
32
|
+
ignore(b.metadata["foo"])
|
|
33
|
+
|
|
34
|
+
if
|
|
35
|
+
# If A and B are not too loud and close, fully cross-fade them.
|
|
36
|
+
a.db_level <= medium
|
|
37
|
+
and
|
|
38
|
+
b.db_level <= medium
|
|
39
|
+
and
|
|
40
|
+
abs(a.db_level - b.db_level) <= margin
|
|
41
|
+
then
|
|
42
|
+
log(
|
|
43
|
+
"Old <= medium, new <= medium and |old-new| <= margin."
|
|
44
|
+
)
|
|
45
|
+
log(
|
|
46
|
+
"Old and new source are not too loud and close."
|
|
47
|
+
)
|
|
48
|
+
log(
|
|
49
|
+
"Transition: crossed, fade-in, fade-out."
|
|
50
|
+
)
|
|
51
|
+
add(fade.out(a.source), fade.in(b.source))
|
|
52
|
+
elsif
|
|
53
|
+
# If B is significantly louder than A, only fade-out A.
|
|
54
|
+
# We don't want to fade almost silent things, ask for >medium.
|
|
55
|
+
b.db_level >= a.db_level + margin
|
|
56
|
+
and
|
|
57
|
+
a.db_level >= medium
|
|
58
|
+
and
|
|
59
|
+
b.db_level <= high
|
|
60
|
+
then
|
|
61
|
+
log(
|
|
62
|
+
"new >= old + margin, old >= medium and new <= high."
|
|
63
|
+
)
|
|
64
|
+
log(
|
|
65
|
+
"New source is significantly louder than old one."
|
|
66
|
+
)
|
|
67
|
+
log(
|
|
68
|
+
"Transition: crossed, fade-out."
|
|
69
|
+
)
|
|
70
|
+
add(fade.out(a.source), b.source)
|
|
71
|
+
elsif
|
|
72
|
+
# Opposite as the previous one.
|
|
73
|
+
a.db_level >= b.db_level + margin
|
|
74
|
+
and
|
|
75
|
+
b.db_level >= medium
|
|
76
|
+
and
|
|
77
|
+
a.db_level <= high
|
|
78
|
+
then
|
|
79
|
+
log(
|
|
80
|
+
"old >= new + margin, new >= medium and old <= high"
|
|
81
|
+
)
|
|
82
|
+
log(
|
|
83
|
+
"Old source is significantly louder than new one."
|
|
84
|
+
)
|
|
85
|
+
log(
|
|
86
|
+
"Transition: crossed, fade-in."
|
|
87
|
+
)
|
|
88
|
+
add(a.source, fade.in(b.source))
|
|
89
|
+
elsif
|
|
90
|
+
# Do not fade if it's already very low.
|
|
91
|
+
b.db_level >= a.db_level + margin
|
|
92
|
+
and
|
|
93
|
+
a.db_level <= medium
|
|
94
|
+
and
|
|
95
|
+
b.db_level <= high
|
|
96
|
+
then
|
|
97
|
+
log(
|
|
98
|
+
"new >= old + margin, old <= medium and new <= high."
|
|
99
|
+
)
|
|
100
|
+
log(
|
|
101
|
+
"Do not fade if it's already very low."
|
|
102
|
+
)
|
|
103
|
+
log(
|
|
104
|
+
"Transition: crossed, no fade."
|
|
105
|
+
)
|
|
106
|
+
add(a.source, b.source)
|
|
107
|
+
|
|
108
|
+
# What to do with a loud end and a quiet beginning ?
|
|
109
|
+
# A good idea is to use a jingle to separate the two tracks,
|
|
110
|
+
# but that's another story.
|
|
111
|
+
else
|
|
112
|
+
# Otherwise, A and B are just too loud to overlap nicely, or the
|
|
113
|
+
# difference between them is too large and overlapping would completely
|
|
114
|
+
# mask one of them.
|
|
115
|
+
log(
|
|
116
|
+
"No transition: using default."
|
|
117
|
+
)
|
|
118
|
+
default(a.source, b.source)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
aac_mimes =
|
|
2
|
+
[
|
|
3
|
+
"audio/aac",
|
|
4
|
+
"audio/aacp",
|
|
5
|
+
"audio/3gpp",
|
|
6
|
+
"audio/3gpp2",
|
|
7
|
+
"audio/mp4",
|
|
8
|
+
"audio/MP4A-LATM",
|
|
9
|
+
"audio/mpeg4-generic",
|
|
10
|
+
"audio/x-hx-aac-adts"
|
|
11
|
+
]
|
|
12
|
+
aac_filexts = ["m4a", "m4b", "m4p", "m4v", "m4r", "3gp", "mp4", "aac"]
|
|
13
|
+
|
|
14
|
+
# Faad is not very selective so we are checking only file that end with a known
|
|
15
|
+
# extension or mime type
|
|
16
|
+
def faad_test(fname) =
|
|
17
|
+
# Get the file's mime
|
|
18
|
+
mime = file.mime(fname) ?? ""
|
|
19
|
+
|
|
20
|
+
# Test mime
|
|
21
|
+
if
|
|
22
|
+
list.mem(mime, aac_mimes)
|
|
23
|
+
then
|
|
24
|
+
true
|
|
25
|
+
else
|
|
26
|
+
# Otherwise test file extension
|
|
27
|
+
ret = string.extract(pattern="\\.(.+)$", fname)
|
|
28
|
+
if
|
|
29
|
+
list.length(ret) != 0
|
|
30
|
+
then
|
|
31
|
+
ext = ret[1]
|
|
32
|
+
list.mem(ext, aac_filexts)
|
|
33
|
+
else
|
|
34
|
+
false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if
|
|
40
|
+
process.test(
|
|
41
|
+
"which faad"
|
|
42
|
+
)
|
|
43
|
+
then
|
|
44
|
+
log(
|
|
45
|
+
level=3,
|
|
46
|
+
"Found faad binary: enabling external faad decoder and metadata resolver."
|
|
47
|
+
)
|
|
48
|
+
faad_p =
|
|
49
|
+
(
|
|
50
|
+
fun (f) ->
|
|
51
|
+
"faad -w #{process.quote(f)} 2>/dev/null"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def test_faad(fname) =
|
|
55
|
+
if
|
|
56
|
+
faad_test(fname)
|
|
57
|
+
then
|
|
58
|
+
channels =
|
|
59
|
+
list.hd(
|
|
60
|
+
default="",
|
|
61
|
+
process.read.lines(
|
|
62
|
+
"faad -i #{process.quote(fname)} 2>&1 | grep 'ch,'"
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
ret =
|
|
66
|
+
string.extract(
|
|
67
|
+
pattern=
|
|
68
|
+
", (\\d) ch,",
|
|
69
|
+
channels
|
|
70
|
+
)
|
|
71
|
+
ret =
|
|
72
|
+
if
|
|
73
|
+
list.length(ret) == 0
|
|
74
|
+
then
|
|
75
|
+
# If we pass the faad_test, chances are high that the file will
|
|
76
|
+
# contain aac audio data..
|
|
77
|
+
"-1"
|
|
78
|
+
else
|
|
79
|
+
ret[1]
|
|
80
|
+
end
|
|
81
|
+
int_of_string(default=(-1), ret)
|
|
82
|
+
else
|
|
83
|
+
0
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
decoder.oblivious.add(
|
|
88
|
+
name="FAAD",
|
|
89
|
+
description=
|
|
90
|
+
"Decode files using the faad binary.",
|
|
91
|
+
test=test_faad,
|
|
92
|
+
faad_p
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def faad_meta(~metadata=_, file) =
|
|
96
|
+
if
|
|
97
|
+
faad_test(file)
|
|
98
|
+
then
|
|
99
|
+
ret =
|
|
100
|
+
process.read.lines(
|
|
101
|
+
"faad -i #{process.quote(file)} 2>&1"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Yea, this is tuff programming (again)!
|
|
105
|
+
def get_meta(l, s) =
|
|
106
|
+
ret = string.extract(pattern="^(\\w+):\\s(.+)$", s)
|
|
107
|
+
if
|
|
108
|
+
list.length(ret) > 0
|
|
109
|
+
then
|
|
110
|
+
list.append([(ret[1], ret[2])], l)
|
|
111
|
+
else
|
|
112
|
+
l
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
list.fold(get_meta, [], ret)
|
|
116
|
+
else
|
|
117
|
+
[]
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
decoder.metadata.add("FAAD", faad_meta)
|
|
122
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
flac_p = "/usr/bin/flac"
|
|
2
|
+
|
|
3
|
+
def test_flac(f) =
|
|
4
|
+
if process.test("which metaflac") then
|
|
5
|
+
channels = list.hd(default="",process.read.lines("metaflac --show-channels #{process.quote(f)} 2>/dev/null"))
|
|
6
|
+
#If the value is not an int, this returns 0 and we are ok :)
|
|
7
|
+
int_of_string(channels)
|
|
8
|
+
else
|
|
9
|
+
if string.match(pattern="flac", f) then
|
|
10
|
+
# We do not know the number of audio channels so setting to -1
|
|
11
|
+
(-1)
|
|
12
|
+
else
|
|
13
|
+
# All tests failed: no audio decodable using flac..
|
|
14
|
+
0
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
decoder.add(name="FLAC", description="Decode files using the flac decoder binary.", test=test_flac, flac_p)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
if process.test("which metaflac") then
|
|
2
|
+
log(level=3,"Found metaflac binary: enabling flac external metadata resolver.")
|
|
3
|
+
|
|
4
|
+
def flac_meta(~metadata=_, fname)
|
|
5
|
+
ret = process.read.lines("metaflac --export-tags-to=- #{process.quote(fname)} 2>/dev/null")
|
|
6
|
+
ret = list.map(fun(s)->string.split(separator="=",s), ret)
|
|
7
|
+
|
|
8
|
+
# Could be made better.
|
|
9
|
+
def f(l',l)=
|
|
10
|
+
if list.length(l) >= 2 then
|
|
11
|
+
list.append([(list.hd(default="",l),list.nth(default="",l,1))], l')
|
|
12
|
+
else
|
|
13
|
+
if list.length(l) >= 1 then
|
|
14
|
+
list.append([(list.hd(default="",l),"")], l')
|
|
15
|
+
else
|
|
16
|
+
l'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
list.fold(f, [], ret)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
decoder.metadata.add("FLAC", flac_meta)
|
|
24
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
settings.init.force_start := true
|
|
2
|
+
settings.server.telnet := true
|
|
3
|
+
|
|
4
|
+
# Replace the path here with a path to some video files:
|
|
5
|
+
s = playlist("/path/to/files")
|
|
6
|
+
|
|
7
|
+
streams = ref([])
|
|
8
|
+
count = ref(0)
|
|
9
|
+
|
|
10
|
+
enc = %ffmpeg(format = "flv", %audio.copy, %video.copy)
|
|
11
|
+
|
|
12
|
+
def create_stream(url) =
|
|
13
|
+
if
|
|
14
|
+
list.assoc.mem(url, streams())
|
|
15
|
+
then
|
|
16
|
+
"Stream for url #{url} already exists!"
|
|
17
|
+
else
|
|
18
|
+
out = output.url(id="restream-#{count()}", fallible=true, url=url, enc, s)
|
|
19
|
+
count := count() + 1
|
|
20
|
+
streams := [...streams(), (url, out.shutdown)]
|
|
21
|
+
"OK!"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete_stream(url) =
|
|
26
|
+
if
|
|
27
|
+
not list.assoc.mem(url, streams())
|
|
28
|
+
then
|
|
29
|
+
"Stream for url #{url} does not exists!"
|
|
30
|
+
else
|
|
31
|
+
shutdown = list.assoc(url, streams())
|
|
32
|
+
shutdown()
|
|
33
|
+
streams := list.filter((fun (el) -> fst(el) != url), streams())
|
|
34
|
+
"OK!"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
server.register(
|
|
39
|
+
namespace="restream",
|
|
40
|
+
description=
|
|
41
|
+
"Redirect a stream.",
|
|
42
|
+
usage=
|
|
43
|
+
"start <url>",
|
|
44
|
+
"start",
|
|
45
|
+
create_stream
|
|
46
|
+
)
|
|
47
|
+
server.register(
|
|
48
|
+
namespace="restream",
|
|
49
|
+
description=
|
|
50
|
+
"Stop a dynamic playlist.",
|
|
51
|
+
usage=
|
|
52
|
+
"stop <url>",
|
|
53
|
+
"stop",
|
|
54
|
+
delete_stream
|
|
55
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
def dynamic_volume(s) =
|
|
2
|
+
def mkfilter(graph) =
|
|
3
|
+
filter = ffmpeg.filter.volume.create(graph)
|
|
4
|
+
|
|
5
|
+
def set_volume(v) =
|
|
6
|
+
ignore(filter.process_command("volume", "#{v}"))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
let {audio = audio_track} = source.tracks(s)
|
|
10
|
+
|
|
11
|
+
audio_track = ffmpeg.filter.audio.input(graph, audio_track)
|
|
12
|
+
filter.set_input(audio_track)
|
|
13
|
+
audio_track = filter.output
|
|
14
|
+
audio_track = ffmpeg.filter.audio.output(graph, audio_track)
|
|
15
|
+
|
|
16
|
+
s =
|
|
17
|
+
source(
|
|
18
|
+
{
|
|
19
|
+
audio=audio_track,
|
|
20
|
+
metadata=track.metadata(audio_track),
|
|
21
|
+
track_marks=track.track_marks(audio_track)
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
(s, set_volume)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
ffmpeg.filter.create(mkfilter)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
s = playlist("my_playlist")
|
|
32
|
+
|
|
33
|
+
let (s, set_volume) = dynamic_volume(s)
|
|
34
|
+
# END
|
|
35
|
+
output.dummy(fallible=true, s)
|
|
36
|
+
ignore(set_volume)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
def flanger_highpass(audio_track) =
|
|
2
|
+
def mkfilter(graph) =
|
|
3
|
+
audio_track = ffmpeg.filter.audio.input(graph, audio_track)
|
|
4
|
+
audio_track = ffmpeg.filter.flanger(graph, audio_track, delay=10.)
|
|
5
|
+
audio_track = ffmpeg.filter.highpass(graph, audio_track, frequency=4000.)
|
|
6
|
+
ffmpeg.filter.audio.output(graph, audio_track)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
ffmpeg.filter.create(mkfilter)
|
|
10
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
def hflip(s) =
|
|
2
|
+
def mkfilter(graph) =
|
|
3
|
+
let { audio = audio_track, video = video_track} = source.tracks(s)
|
|
4
|
+
|
|
5
|
+
video_track = ffmpeg.filter.video.input(graph, video_track)
|
|
6
|
+
video_track = ffmpeg.filter.hflip(graph, video_track)
|
|
7
|
+
|
|
8
|
+
audio_track = ffmpeg.filter.audio.input(graph, audio_track)
|
|
9
|
+
audio_track = ffmpeg.filter.acopy(graph, audio_track)
|
|
10
|
+
|
|
11
|
+
video_track = ffmpeg.filter.video.output(graph, video_track)
|
|
12
|
+
audio_track = ffmpeg.filter.audio.output(graph, audio_track)
|
|
13
|
+
|
|
14
|
+
source({
|
|
15
|
+
audio = audio_track,
|
|
16
|
+
video = video_track,
|
|
17
|
+
metadata = track.metadata(audio_track),
|
|
18
|
+
track_marks = track.track_marks(audio_track)
|
|
19
|
+
})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ffmpeg.filter.create(mkfilter)
|
|
23
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
def parallel_flanger_highpass(s) =
|
|
2
|
+
def mkfilter(graph) =
|
|
3
|
+
audio_track = ffmpeg.filter.audio.input(graph, s.tracks.audio)
|
|
4
|
+
|
|
5
|
+
let (audio, _) = ffmpeg.filter.asplit(outputs=2, graph, audio_track)
|
|
6
|
+
|
|
7
|
+
let [a1, a2] = audio
|
|
8
|
+
|
|
9
|
+
a1 = ffmpeg.filter.flanger(graph, a1, delay=10.)
|
|
10
|
+
a2 = ffmpeg.filter.highpass(graph, a2, frequency=4000.)
|
|
11
|
+
|
|
12
|
+
# For some reason, we need to enforce the format here.
|
|
13
|
+
a1 =
|
|
14
|
+
ffmpeg.filter.aformat(
|
|
15
|
+
sample_fmts="s16",
|
|
16
|
+
sample_rates="44100",
|
|
17
|
+
channel_layouts="stereo",
|
|
18
|
+
graph,
|
|
19
|
+
a1
|
|
20
|
+
)
|
|
21
|
+
a2 =
|
|
22
|
+
ffmpeg.filter.aformat(
|
|
23
|
+
sample_fmts="s16",
|
|
24
|
+
sample_rates="44100",
|
|
25
|
+
channel_layouts="stereo",
|
|
26
|
+
graph,
|
|
27
|
+
a2
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
audio_track = ffmpeg.filter.amerge(inputs=2, graph, [a1, a2], [])
|
|
31
|
+
|
|
32
|
+
ffmpeg.filter.audio.output(graph, audio_track)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
ffmpeg.filter.create(mkfilter)
|
|
36
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
s1 = input.rtmp(listen=false, "rtmp://....")
|
|
2
|
+
s1 = ffmpeg.filter.bitstream.h264_mp4toannexb(s1)
|
|
3
|
+
|
|
4
|
+
s2 = playlist("/path/to/playlist")
|
|
5
|
+
s2 = ffmpeg.filter.bitstream.h264_mp4toannexb(s2)
|
|
6
|
+
|
|
7
|
+
s = fallback(track_sensitive=false, [s1, s2])
|
|
8
|
+
|
|
9
|
+
mpegts =
|
|
10
|
+
%ffmpeg(format = "mpegts", fflags = "-autobsf", %audio.copy, %video.copy)
|
|
11
|
+
|
|
12
|
+
streams = [("mpegts", mpegts)]
|
|
13
|
+
|
|
14
|
+
output_dir = "/tmp/hls"
|
|
15
|
+
|
|
16
|
+
output.file.hls(
|
|
17
|
+
playlist="live.m3u8",
|
|
18
|
+
fallible=true,
|
|
19
|
+
segment_duration=5.,
|
|
20
|
+
output_dir,
|
|
21
|
+
streams,
|
|
22
|
+
s
|
|
23
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
stream = input.http(start = false, "https://wwoz-sc.streamguys1.com/wwoz-hi.mp3")
|
|
2
|
+
|
|
3
|
+
listeners_count = ref(0)
|
|
4
|
+
|
|
5
|
+
def on_connect(~headers=_, ~uri=_, ~protocol=_, _) =
|
|
6
|
+
listeners_count := listeners_count() + 1
|
|
7
|
+
if listeners_count() > 0 and not stream.is_started() then
|
|
8
|
+
log("Starting input")
|
|
9
|
+
stream.start()
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def on_disconnect(_) =
|
|
14
|
+
listeners_count := listeners_count() - 1
|
|
15
|
+
if listeners_count() == 0 and stream.is_started() then
|
|
16
|
+
log("Stopping input")
|
|
17
|
+
stream.stop()
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
blank = single("/tmp/blank.mp3")
|
|
22
|
+
|
|
23
|
+
stream = fallback(track_sensitive=false, [stream, blank])
|
|
24
|
+
|
|
25
|
+
output.harbor(
|
|
26
|
+
%ffmpeg(format="mp3", %audio.copy),
|
|
27
|
+
format="audio/mpeg",
|
|
28
|
+
mount="relay",
|
|
29
|
+
on_connect=on_connect,
|
|
30
|
+
on_disconnect=on_disconnect,
|
|
31
|
+
stream)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Input the stream,
|
|
2
|
+
# from an Icecast server or any other source
|
|
3
|
+
encoded_source = input.http("https://icecast.radiofrance.fr/fip-hifi.aac")
|
|
4
|
+
|
|
5
|
+
# Send to one server here:
|
|
6
|
+
output.icecast(
|
|
7
|
+
%ffmpeg(format="adts", %audio.copy),
|
|
8
|
+
fallible=true,
|
|
9
|
+
mount="/restream",
|
|
10
|
+
host="streaming.example.com", port=8000, password="xxx",
|
|
11
|
+
encoded_source)
|
|
12
|
+
|
|
13
|
+
# An another one here:
|
|
14
|
+
output.icecast(
|
|
15
|
+
%ffmpeg(format="adts", %audio.copy),
|
|
16
|
+
fallible=true,
|
|
17
|
+
mount="/restream",
|
|
18
|
+
host="streaming2.example.com", port=8000, password="xxx",
|
|
19
|
+
encoded_source)
|