Skip to content

gavalierm/srt-restreamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

194 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

srt-distributor

Custom srt-distributor bash app with ffmpeg binary

Installation

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-distributor

I recommend use SSH connection with RSA auth.

Structure

Folder: ffmpeg

Placeholder for ffmpeg binary

Folder: in-configs

Contains all "in-going endpoints" configurations

Folder: out-configs

Contains all "out-going endpoints" subfolders with configurations

Script: auto_tmuxer.sh

Super handy script to run whole distributor from single script Params: Accepting only single param "basename of in-going config" Example:

./auto_tmuxer.sh pp

Script: distributor.sh

Distributing defined in-going stream to localhost multicast stream Params: Accepting single param "path to in-config file" Example:

./distributor.sh in-configs/pp.conf

Script: endpoint.sh

Distributing 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.conf

Configurations

In-going points > in-configs

For 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.conf

Req

PORT=9123
UDP_LOCAL_IP=239.0.0.1

Port 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

IMPORTANT NOTE

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.

Additional/Optional

PKILL=default

PKILL 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=default

To force kill with -9 flag

PKILL=force

To wait 6 seconds and then force kill

PKILL=wait_6

To wait 30 seconds and then force kill

PKILL=wait_30

Never kill sub-ffmpegs (do not recommend, can hookup the whole restreamer)

PKILL=nokill

Use TMUX version of soft kill using sending TMUX commnad "q" to matched window

PKILL=qkill

Out-going points > out-configs

For 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 -lah

Create "out point" file

mkdir example_outs
cd example_outs
vim yt_out_example.conf

Req

TYPE=yt
KEY=REDACTED

TYPE: accepting "service privider type": yt,fb,ig

KEY: Any correct stream key for the TYPE

Additional/Optional

KEY_PATH=local_dir/local_sub_dir/some_key_file.name

KEY_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=100058624

SOURCE URL is provied to ignore udp bridge and use this url as input stream source Usefull for Instagram streams

UNIX Modifications

Because this restreamer use UDP LOCALHOST MULTICAST bridge from in to out you need modify standard UNIX interface behavior like so:

DISABLE MULTICAST ON ETH interface

  ifconfig ens18 -multicast

ENABLE MULTICAST ON LO interface

  ifconfig lo multicast

ADD MULTICAST LOOPBACK route

  route add -net 239.0.0.0 netmask 255.255.255.254 dev lo

Why 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.

Install cron script for reboot

@reboot sleep 5; bash ~/srt-restreamer/cron.sh

Note: CRON and $USER var

Because 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

Support

For support, email marcel@gavalier.sk, drlik.zbynek@gmail.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages