-
Notifications
You must be signed in to change notification settings - Fork 1
Rtmp relay #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Rtmp relay #36
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ set("request.deprecated_on_air_metadata", true) | |
|
|
||
| #set("server.telnet",true) | ||
| set("server.socket",true) | ||
| # set("server.socket.path","/tmp/datafruits/liquidsoap.sock") | ||
| set("server.socket.path","/home/liquidsoap/tracks/liquidsoap.sock") | ||
|
|
||
| set("harbor.bind_addrs",["0.0.0.0"]) | ||
|
|
@@ -43,6 +44,7 @@ stop_dump_f = ref (fun () -> ()) | |
|
|
||
| # live_dj = ref empty() | ||
| live_dj = ref(source.fail()) | ||
| # rtmp_relay = ref(source.fail()) | ||
| # fallback_ref = ref(fallback([source.fail()])) | ||
|
|
||
| def icy_update(v) = | ||
|
|
@@ -85,7 +87,7 @@ def dj_dummy_stopped() = | |
| f() | ||
| end | ||
|
|
||
| def get_user(user,password) = | ||
| def get_user(user, password) = | ||
| if user == "source" then | ||
| x = string.split(separator=';',password) | ||
| list.nth(x,0,default="") | ||
|
|
@@ -94,7 +96,7 @@ def get_user(user,password) = | |
| end | ||
| end | ||
|
|
||
| def get_password(user,password) = | ||
| def get_password(user, password) = | ||
| if user == "source" then | ||
| x = string.split(separator=';',password) | ||
| list.nth(x,1,default="") | ||
|
|
@@ -104,10 +106,10 @@ def get_password(user,password) = | |
| end | ||
|
|
||
| #auth function | ||
| def dj_auth(params) = | ||
| def dj_auth(req) = | ||
| log("dj auth") | ||
| u = get_user(params.user,params.password) | ||
| p = get_password(params.user,params.password) | ||
| u = get_user(req.user, req.password) | ||
| p = get_password(req.user, req.password) | ||
| ret = process.read.lines("./dj_auth.sh '#{u}' '#{p}' '#{radio_name}'") | ||
| #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" | ||
| ret = list.hd(default="",ret) | ||
|
|
@@ -226,6 +228,18 @@ end | |
| # buffer breaks fallback? | ||
| live_dj := stereo(input.harbor("#{radio_name}",id="live_dj",port=9000,auth=dj_auth,on_connect=on_connect,on_disconnect=on_disconnect,logfile="/tmp/liquidsoap_harbor.log",buffer=15.0,max=40.0)) | ||
|
|
||
| # this source doesn't need on_connect handler, all recording/metadata is handled elsewhere | ||
| # disconnect handler to clear metadata is necessary though | ||
| # rtmp_relay := stereo(input.harbor("#{radio_name}_rtmp",id="rtmp_relay",port=9001,logfile="/tmp/liquidsoap_rtmp_relay_harbor.log",user="rtmp_source",password="pricemaster9876",on_disconnect=on_disconnect,buffer=15.0,max=40.0)) | ||
|
|
||
| # ingest rtmp from viz server | ||
|
|
||
| # how do we get the key?! | ||
| # live = input.rtmp(listen=false, "rtmp://localhost:1935/live/key") | ||
| # live = input.rtmp(listen=false, "rtmp://vjstream.streampusher.com:1935/live/key") | ||
|
|
||
| # rtmp = input.rtmp("rtmp://0.0.0.0:1935/live", listen=true) | ||
|
|
||
| # live_dj := input.harbor( | ||
| # "liq_live_dj", | ||
| # port=9000, | ||
|
|
@@ -293,8 +307,13 @@ end | |
|
|
||
| output.file(%mp3, current_dump_filename_getter, live_dj(), fallible=true, reopen_when=reopen_when, reopen_delay=0.0, append=true) | ||
|
|
||
| # nginx-rtmp pushes the live RTMP stream here when a DJ is streaming with obs | ||
| rtmp_relay = input.rtmp(listen=true, "rtmp://datafruits_viz:1936") | ||
| # TODO uncommenting this causes type error | ||
| rtmp_audio = stereo(source.tracks(rtmp_relay).audio) | ||
|
|
||
| source = fallback(id="fallback",track_sensitive=false, | ||
| [live_dj(),scheduled_shows,mksafe(id="backup_playlist_mksafe", backup_playlist)]) | ||
| [rtmp_audio, live_dj(),scheduled_shows,mksafe(id="backup_playlist_mksafe", backup_playlist)]) | ||
|
|
||
| source.on_metadata(synchronous=false, pub_metadata) | ||
|
|
||
|
|
@@ -336,3 +355,32 @@ output.icecast(%mp3,id="icecast", | |
| send_icy_metadata=true,description="", | ||
| url="", encoding="UTF-8", | ||
| mksafe(buffer(source))) | ||
|
|
||
| # HLS video output | ||
|
|
||
| hls_audio_fallback = fallback(id="fallback",track_sensitive=false, | ||
| [live_dj(),scheduled_shows,mksafe(id="backup_playlist_mksafe", backup_playlist)]) | ||
|
|
||
| single_video = noise() | ||
|
|
||
| logo_fallback = mux_audio(single_video, audio=hls_audio_fallback) | ||
|
|
||
| # RTMP video takes priority; fall back to static logo + audio | ||
| hls_source = fallback(id="hls_fallback", track_sensitive=false, [rtmp_relay, logo_fallback]) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like an issue where the typechecker thinks the whole audio track is of type |
||
|
|
||
| hls_enc = %ffmpeg( | ||
| format="mpegts", | ||
| %video(codec="libx264", x264opts="keyint=100:min-keyint=100"), | ||
| %audio(codec="aac", channels=2, ar=44100) | ||
| ) | ||
|
|
||
| output.file.hls( | ||
| id="hls_output", | ||
| playlist="live.m3u8", | ||
| segment_duration=4.0, | ||
| segments=5, | ||
| segments_overhead=5, | ||
| "/home/liquidsoap/hls/", | ||
| [("live", hls_enc)], | ||
| hls_source | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect and not needed: the decoder should be able to convert to audio implicitly when needed.