Stream to any OR Multiple RTMP Destinations + Record Simultaneously

Thanks a lot for explaining so clearly. If I understood correctly, here jitsi-meet will pass stream key for youtube only. and internally same key passed to nginx rtmp server. Youtube streamed using jitsi-meet passed stream key and FB live will use static hard coded key mentioned in script.

you have to use respective streamkeys from each provider

the streamkey passed from jitsi to jibri will anyway be dropped by the nginx/rtmp proxy. you can actually put any character in the streamkey dialog box on jitsi-meet. it will still work… its just safer to use a streamkey. you can pretty much us eany key.

Use the CORRECT Stream-key in the nginx.conf file of the rtmp/nginx server though. else it wont work

Thanks

Bow shall you take @masteryoda :pray:t2:

This works very well! I made slight modifications to make it configurable and added it to my Terraform configuration for AWS here:

I have tested it with simulcast streaming to Facebook, YouTube, Periscope/Twitter, and Twitch at the same time. Also made all recordings available under /recordings with basic auth enabled. Wooohoo!

6 Likes

there is a redundant step i guess. if you enable recording folder in jibri & also in the nginx proxy, it will be recorded in 2 places. you can disable in 1 place.

@masteryoda I’m moving Jibri’s recorded files from /tmp/recordings to the webroot in my finalize_recording.sh script that runs after a recording is stopped. So ultimately they all stay under one location on the filesystem.

Ref:

1 Like

Continuing the discussion from Stream to any OR Multiple RTMP Destinations + Record Simultaneously:

This is regarding facebook live script, first of all thanks for posting such a useful script.

I have upgraded ffmpeg in system which support rtmps: protocol , I made a few changes in script to directly send to FB via rtmps://, and my script is as below,

++++++

#!/bin/bash

COMANDO="/usr/local/bin/ffmpeg"
while test $# -gt 0
do
T="1" if [ "{1:0:32}" == “rtmp://a.rtmp.youtube.com/live2/” ]; then
# T will contain the rtmp key from jitsi meet page.
COMANDO="COMANDO rtmps://live-api-s.facebook.com:443/rtmp/{T:32}"
else
COMANDO="$COMANDO $T"
fi
shift
done
echo “$COMANDO”>/tmp/logs
#exec COMANDO #PROCESS_FFMPEG=!
#wait $PROCESS_FFMPEG
$COMANDO
++++
and can in logs that below command getting executed ,
/usr/local/bin/ ffm peg -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i plug:cloop -acodec aac -strict -2 -ar 44100 -c:v libx264 -preset veryfast -maxrate 2976k -bufsize 5952k -pix_fmt yuv420p -r 30 -crf 25 -g 60 -tune zerolatency -f flv rtmps://live-api-s.facebook.com:443/rtmp/2952996061451936?s_bl=1&s_sc=2952996121451930&s_sw=0&s_vt=api-s&a=AbyCwP8KZbDGAq7_

But on FaceBook live, no audio video is coming just a simple screenshot with log in event that “Live service received the video”

is it frame rate or codec issue ?

ok.

just remember that jibri on its own can only stream OR record not both. thats why i’ve removed the record button in my setup and do all recording (if required) using the nginx/rtmp server .

one more thing. you must install prosody 0.11.x for secure domain + room password to work. else if you set a room password or meeting password, jibri will not work

i dont think it will work. the streamkey for FB is not the same as YT. so if you dont use the nginx/rtmp proxy you can only stream to FB OR Youtube.

Yes right, its not a final script I was just testing with FaceBook without apache and stunnel as my ffmpeg support rtmps:// . This script is serving purpose by changing url for FaceBook , and I can notice same in ps -ef and log
+++++
/usr/local/bin/ ffm peg -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i plug:cloop -acodec aac -strict -2 -ar 44100 -c:v libx264 -preset veryfast -maxrate 2976k -bufsize 5952k -pix_fmt yuv420p -r 30 -crf 25 -g 60 -tune zerolatency -f flv rtmps://live-api-s.facebook.com:443/rtmp/xxxxxxxxxxyyyy?s_bl=1&s_sc=2952996121451930&s_sw=0&s_vt=api-s&a=AbyCwP8KZbDGAq7_
++++++++++

But audio/video not coming on facebook live , despite events log of Facebook says video received

Does YouTube and FaceBook not support same ffmpeg options like bitrate/codec. Facebook receiving my command on live url using stream key , but video and audio not coming

i guess not… FB requirements are quite finicky, so not sure…

Thanks masteryoda , for your excellent idea of achieve FB live through script

I able to solve the problem and now can stream directly to Facebook live without Apache and Stunnel given that ffmpeg support rtmps: protocol. This script check stream key and if stream is of pattern of Facebook Live then stream to Facebook Live else stream to YouTube

below script served the purpose
++++++++
#!/bin/bash

COMANDO="/usr/local/bin/ffmpeg"
while test $# -gt 0
do
T="1" if [ "{1:0:32}" == “rtmp://a.rtmp.youtube.com/live2/” ]; then
# T will contain the rtmp key from jitsi meet page.
streamkey=${T:32}
if [[ $streamkey == “s_sc=” ]]; then
COMANDO="COMANDO rtmps://live-api-s.facebook.com:443/rtmp/{T:32}"
else
COMANDO="$COMANDO $T"
fi
else
COMANDO="$COMANDO $T"
fi
shift
done
echo “$COMANDO”>>/tmp/logs
exec COMANDO PROCESS_FFMPEG=!
wait $PROCESS_FFMPEG
$COMANDO
+++++++++++++++++++

Just make sure ffmpeg support rtmps: protocol.

ffmpeg -protocols|grep rtmps

Note: This only stream to Facebook live or Youtube , not any other platform

I think You can make it stream to both…

Just drop the key that put in popup window and use permanent keys in the script & see if that works

Yes right, but my requirement was to either stream to Facebook or YouTube, and stream key need to be provided in each conference.

Thanks

worked like a charm, thanks alot !!

@masteryoda

would it work right if i want to serve RTMP stream over a client in a local environment.

means, if i have a rtmp server running locally on the same vm/machine as jibri, would i just give the rmtp url as 127.0.0.1/stream or something like that?

would it reduce the load of sending out to another rtmp server and instead self-host the server? as you can, please share your thoughts on this.

yes, that should work. you need nginx on jibri though

1 Like

Yes, works like a charm. I have Jibri and this installed on a 4core/16GB GCP instance with a static ffmpeg build (4.2.2) and it’s working well. The only issue is that stopping the live stream doesn’t stop the live event on Vimeo automatically.

1 Like

i dont know about vimeo. YT (you have to enable auto-stop) periscope and facebook (again enable auto-stop) does stop automatically though when you stop streaming

OK - I figured it out - there’s a 5-minute time-out window after the stream stops before it auto-stops… Thanks for the solution - it solves a lot of problems without having to hack the code!

1 Like