streamupload/README.md
gitlab.com/pepa65 93b8083285 Reorder readme
2022-09-08 09:40:56 +07:00

3.6 KiB

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).
  • On the server, cd to the place where you want the files (make sure that the webserver user (often www-data) has access to the location!).
  • Make sure the packages git php-fpm ffmpeg are installed (on deb-based systems: apt install git php-fpm ffmpeg).
  • Clone repo: git clone https://gitlab.com/pepa65/streamupload.
  • cd streamupload. Now the output of pwd is the value for $repopath.
  • Copy _vars to vars and set the variables to, user, password, smtp and port in it in order to receive mail notifications when the encodes are finished.
  • Make a crontab-entry: "* * * * * $repopath/encode" (replace $repopath!).
  • Install the mailer binary by downloading it from the repo at https://https://github.com/pepa65/mailer/releases/latest and moving it to /usr/local/bin and make it executable: chmod +x /usr/local/bin/mailer. If it's not installed, everything except the email will still work.
  • Run a php/webserver on $repopath/uploadpage:
    • Get it to restart on reboot.
    • Setting up basicauth on the page is a good idea if others can get access!
    • Change the relevant php.ini to allow large file uploads:
      • post_max_size - Upper limit of uploaded video sizes, say 10G.
      • upload_max_filesize - same value as post_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. For php functionality, install php-fpm (on deb-based systems: apt install php-fpm) and make the config file /root/Caddyfile with:

:80 {
	basicauth {
		$user $hashpassword
	}
	php_fastcgi unix//run/php/php-fpm.sock
	root * $repopath/uploadpage
	file_server
}
  • If the server IP has an DNS A record pointing to it, :80 can be replaced by the domainname with the A record.
  • Replace $user with the desired username for authentication.
  • Replace $hashpassword with the output of caddy hash-password which will ask for the password to be used for authentication.
  • Replace $repopath (see above in Install).
  • The value of /run/php/php-fpm.sock might 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/Caddy as a line in root's crontab: crontab -e and make the file /root/Caddy with:
#!/usr/bin/env bash

# Make sure internet is reachable
while ! /usr/bin/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
/usr/bin/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 and cd streamupload, 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/uploadpage:/var/www/uploadpage 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 IP address in the browser: http://$ipaddress or to the domainname if available: https://$domainname.
  • Fill in the form, and click "Schedule Stream".