Custom srt-distributor bash app with ffmpeg binary
Install srt-distributor with git. You need your git hub credentials or you have to use RSA auth.
git clone "git@github.com:gavalierm/srt-restreamer.git"
cd srt-distributorI recommend use SSH connection with RSA auth.
Placeholder for ffmpeg binary
Contains all "in-going endpoints" configurations
Contains all "out-going endpoints" subfolders with configurations
Super handy script to run whole distributor from single script Params: Accepting only single param "basename of in-going config" Example:
./auto_tmuxer.sh ppDistributing defined in-going stream to localhost multicast stream Params: Accepting single param "path to in-config file" Example:
./distributor.sh in-configs/pp.confDistributing defined localhost multicast stream to out-going point Params: Accepting two params "path to in-config file" and "path to out-config file" Example:
./distributor.sh in-configs/pp.conf out-configs/pp/youtube.confFor add in-going point you need to create in point file (example.conf) with common ENV structure. Temporary files can be exluded from auto_tmuxer by adding ".ignore" to filename.
Create "out point" file
cd in-configs
vim example_in.confPORT=9123
UDP_LOCAL_IP=239.0.0.1Port is defined tcp/ip port for SRT in-going stream from your stream app (obs/vmix). Accepting all valid TCP/IP ports. Note: See how to tweak UNIX distro for UDP localhost bridge UNIX Modifications
srt-distributor use in-config PORT in various formats. For UDP localhost restreaming point is used "1" + "PORT". So port 9999 becomes 19999 for internal udp bridge. Keep this in mind.
PKILL=defaultPKILL is "debug reason variable" for futher tests with sub-ffmpegs killing scenarios.
Accepting: default, force, wait_6, wait_30, nokill, qkill
To trying to soft kill
PKILL=defaultTo force kill with -9 flag
PKILL=forceTo wait 6 seconds and then force kill
PKILL=wait_6To wait 30 seconds and then force kill
PKILL=wait_30Never kill sub-ffmpegs (do not recommend, can hookup the whole restreamer)
PKILL=nokillUse TMUX version of soft kill using sending TMUX commnad "q" to matched window
PKILL=qkillFor add out-going point you need to create out point file (yt_out_example.conf) with common ENV structure in "out-configs" folder.
IMPORTANT NOTE: In out-configs folder you need to create (if not exists) sub-folder with matched name as your in-config basename.
cd out-configs
ls -lahCreate "out point" file
mkdir example_outs
cd example_outs
vim yt_out_example.confTYPE=yt
KEY=REDACTEDTYPE: accepting "service privider type": yt,fb,ig
KEY: Any correct stream key for the TYPE
KEY_PATH=local_dir/local_sub_dir/some_key_file.nameKEY_PATH is special feature to overwrite static KEY value with "file loaded". KEY provided in KEY_PATH will be periodically refreshed in ffmpeg loop. Accepting: Any valid local file path
IMPORTANT NOTE: KEY_PATH have to be touched in last 24 hours otherwise will be ignored and ffmpeg loop will be skiped. Usefull for Instagram streams
SOURCE_URL=srt://0.0.0.0:91230?mode=listener&latency=3000000&ffs=128000&rcvbuf=100058624SOURCE URL is provied to ignore udp bridge and use this url as input stream source Usefull for Instagram streams
Because this restreamer use UDP LOCALHOST MULTICAST bridge from in to out you need modify standard UNIX interface behavior like so:
ifconfig ens18 -multicast ifconfig lo multicast route add -net 239.0.0.0 netmask 255.255.255.254 dev loWhy 239.0.0.0 ?
In this example we use 239 because this is default local multicast group. If you use in your in-configs other multicast group like 224.0.0.0 you need add this group to the loopback.
Why 255.255.255.254
In this example we want use multicast bridge only in 1 defined ip (in our case 239.0.0.1). So we mask-out any others groups.
@reboot sleep 5; bash ~/srt-restreamer/cron.shBecause cron dont have access to the $USER var we using simple hack in all scripts. We use 'id' instaed of $USER
#HACK $USER will not work because cron have no access to this variable
RUN_USER=$(id -u -n)
#File cron.sh contains multiuser switch case to determine how auto_tmuxer have to be run with. This file have to be adited when you need install new user
For support, email marcel@gavalier.sk, drlik.zbynek@gmail.com