Upload videos to be re-encoded and scheduled for streaming
| web | ||
| _accounts | ||
| _countdown | ||
| _vars | ||
| .gitignore | ||
| Caddyfile | ||
| convert | ||
| Dockerfile | ||
| encode | ||
| getcron | ||
| init | ||
| LICENSE | ||
| README.md | ||
| stream | ||
streamupload
Upload videos to be re-encoded and scheduled for streaming
Install
Manual
- Prepare a Linux server, set its timezone to the users' timezone
(on deb-based systems:
dpkg-reconfigure tzdata). the webserver user (oftenwww-data) has access to the location!). - Make sure the packages
git php-fpm ffmpegare installed (on deb-based systems:apt install git php-fpm ffmpeg). - Clone repo:
git clone https://gitlab.com/pepa65/streamupload. - Move the
streamuploaddirectory to a place that is accessible to the web server, like:mv streamupload /var/wwwandcdto that place. Now the output ofpwdis the value for$repopath. - do
mkdir "$repopath/web/streams"andchmod 777 "$repopath/web/streams". - Copy
_varstovars,_accountstoaccountsand_countdowntocountdownand set the variables invars(webserver, SMTP-server),accounts(usernames, emails and bcrypt-password-hashes) andcountdown(if any countdown-files can be used). - Make a crontab-entry: "* * * * * $repopath/encode" (replace
$repopath!). - Make a crontab-entry: "@reboot $repopath/restart" (replace
$repopath!). - Install the
mailerbinary by downloading it from the repo at https://https://github.com/pepa65/mailer/releases/latest and moving it to/usr/local/binand make it executable:chmod +x /usr/local/bin/mailer. If it's not installed, everything (except the emails) will still work. - Run a php/webserver on
$repopath/web:- Get it to restart on reboot.
- Change the relevant
php.inito allow large file uploads:post_max_size- Upper limit of uploaded video sizes, say10G.upload_max_filesize- same value aspost_max_size.
Webserver
If no webserver has been installed, an easy way to get going is to use Caddy
from https://caddyserver.com/download and place the caddy binary in
/usr/local/bin and make it executable: chmod +x /usr/local/bin/caddy.
Make the config file /root/Caddyfile like:
{
email $email
}
:80 {
log {
output file $repopath/upload.log
}
php_fastcgi unix//run/php/php-fpm.sock
root * $repopath/web
file_server
}
- If the server IP has an DNS A record pointing to it,
:80can be replaced by the domainname with the A record, and it will be SSL-encrypted. - Replace
$emailwith an email for the SSL-certificates. - Replace
$repopathin both places (see above in Install). - The value of
/run/php/php-fpm.sockmight need to be adjusted, depending on the system used, it needs to be the unix socket for php. - Caddy can be started at boottime by including
@reboot /root/Caddyas a line in root's crontab:crontab -eand make the file/root/Caddywith:
#!/usr/bin/env bash
# Make sure internet is reachable
while ! ping -q -c 1 1.1.1.1 &>/dev/null
do sleep 1
done
cd /root
/usr/local/bin/caddy stop &>/dev/null
sleep 1
killall -9 caddy &>/dev/null
/usr/local/bin/caddy start &>/root/caddy.log
and make it executable: chmod +x /root/Caddy.
Docker
After cloning this repo, cd streamupload, and setting the variables in vars and
accounts, a docker image can be built from the included Dockerfile by:
docker build -t streamupload .. In the case of running on a LAN and not having a
DNS A record, start it with:
docker run -d -p 8080:80 -v $PWD/web:/var/www/web streamupload.
In case of a domainname, replace 8080:80 by 443:443.
Usage
- Get a streamkey for the target by scheduling a stream (supported are: Restream.io, YouTube.com, Facebook.com).
- Go to the server's URL in the browser:
http://$ipaddress:80or for docker:http://$ipaddress:80or in case of a domainname:https://$domainname. - Log in with the username and passwors as prepared in
accounts. - Fill in the form, and click "Schedule Stream".