Install:
Debian 9.1 (amd64 build) from netinst media
DHCP -> vidstream.mcp.lcl
manual partitioning
root: ext4: noatime, discard (20 GB)
swap (1.5 GB)
user: Tom Dobes (tdobes)

no popcon;  tasksel select SSH (deselect everything else, including standard)

> /etc/motd
apt-get --no-install-recommends install aptitude
aptitude install screen rsync psmisc file patch ethtool strace tcpdump vim less net-tools man-db
aptitude --without-recommends install dnsutils
adduser tdobes adm
adduser tdobes systemd-journal
adduser sumistev
(copy password from /etc/shadow on mcpstars.org)
adduser sumistev adm
adduser sumistev systemd-journal
mkdir -p /etc/systemd/system/getty\@tty1.service.d
echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf
systemctl mask keyboard-setup.service
systemctl mask console-setup.service
systemctl mask rc-local.service

aptitude --without-recommends install ffmpeg

aptitude install build-essential git
apt-get build-dep nginx-full

^D (go back to non-root user)
mkdir build
cd build
apt-get source nginx-full
cd nginx-*/debian/modules
git clone git://github.com/arut/nginx-rtmp-module.git
cd ..
vi rules
## put this at the end of full_configure_flags:
## --add-module=$(MODULESDIR)/nginx-rtmp-module
cd ..
FLAVOURS=full dpkg-buildpackage -b
cd ..

su (become root again)
dpkg -i nginx-common_*.deb nginx-full_*.deb libnginx-mod-http-auth-pam_*.deb libnginx-mod-http-dav-ext_*.deb libnginx-mod-http-echo_*.deb libnginx-mod-http-geoip_*.deb libnginx-mod-http-image-filter_*.deb libnginx-mod-http-subs-filter_*.deb libnginx-mod-http-upstream-fair_*.deb libnginx-mod-http-xslt-filter_*.deb libnginx-mod-mail_*.deb libnginx-mod-stream_*.deb

echo >> /etc/nginx/nginx.conf
echo 'include /etc/nginx/rtmp.conf;' >> /etc/nginx/nginx.conf

cat > /etc/nginx/rtmp.conf
rtmp_auto_push on;

rtmp {
  server {
    listen 1935;
    ping 10s;
    ping_timeout 5s;
    drop_idle_publisher 10s;
    application eclipse {
      live on;
      wait_video on;
      #publish_notify on;
      meta copy;
      #push rtmp://a.rtmp.youtube.com app=live2 playpath=TBD;
      #push rtmp://eclipse.mvsc.k12.in.us app=eclipse playpath=live;
      #exec /usr/bin/ffmpeg -re -fflags nobuffer -i rtmp://127.0.0.1/$app/$name -vcodec libx264 -preset veryfast -maxrate 1000k -bufsize 8192k -crf 21 -pix_fmt yuv420p -vf "fps=30" -g 60 -acodec copy -f flv rtmp://a.rtmp.youtube.com/live2/TBD;
      exec /usr/local/bin/ffmpeg -re -fflags nobuffer -i rtmp://127.0.0.1/$app/$name -acodec copy -vcodec copy -f flv rtmp://127.0.0.1/hls/$app;
    }
    application hls {
      live on;
      hls on;
      hls_path /dev/shm/hls;
      hls_fragment 5;
      hls_playlist_length 10;
    }
  }
}
^D

mkdir -p /etc/systemd/system/nginx.service.d
echo '[Service]' > /etc/systemd/system/nginx.service.d/autorestart.conf
echo 'Restart=always' >> /etc/systemd/system/nginx.service.d/autorestart.conf
echo 'RestartSec=1' >> /etc/systemd/system/nginx.service.d/autorestart.conf
echo 'StartLimitInterval=10s' >> /etc/systemd/system/nginx.service.d/autorestart.conf
echo 'StartLimitBurst=10' >> /etc/systemd/system/nginx.service.d/autorestart.conf
systemctl daemon-reload
systemctl restart nginx.service


* To Add: changes to nginx.conf, rtmp.conf, and forking default sites-enabled to stream
* To Add: systemd units and target to run ffmpeg processes
* To Add: sudo so nginx can start/stop systemd unit (exec_publish / exec_publish_done, maybe -- if not, script that does systemctl start, then waits for TERM signal from nginx to run systemctl stop)
computer/vidstream_vm_creation_notes.txt · Last modified: 2017/08/20 22:40 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS