Peer Rails <peer@omck.ws>
Last updated at 2016.09.25
This page also is available at http://docs.omck.tv/
Omck on Rails is the open source multistream view platform built for our game community "OmckTV Videogame Live Stream Channel" It works as:
-
View for Nginx with RTMP module and authentication
-
Twitch channel list
-
Chatroom (but for now we use Twitch chat)
-
Control room for own HD channels
-
If You are new to Rails or advanced Rails developer I still will be happy to accept any help
-
To install please read install guide to set comfortable enviroment for yourself
-
Project has now documentation https://peerrails.github.io/omck-on-rails
Requirements: Ruby 2.3+, Postgres 9.3+
Environment Variable:
-
TICKET_1: TWITTER_POST_CONSUMER_KEY
-
TICKET_2: TWITTER_POST_SECRET_KEY
-
TICKET_3: TWITTER_POST_ACCESS_TOKEN
-
TICKET_4: TWITTER_POST_SECRET_TOKEN
-
LOGIN_AUTH: TWITTER_LOGIN_CONSUMER_KEY
-
LOGIN_SECRET: TWITTER_LOGIN_SECRET_KEY
-
TWITCH_ID: TWITCH_ID
-
SECRET_KEY_BASE: RAILS_SECRET_KEY
-
BITLY_USER: SELF
-
BITLY_TOKEN: SELF
-
Or check config/application.yml.example
-
I use RVM - Ruby Version Manager, it’s great tool to manage ruby projects, installing this tool is recommended. Look at content of .ruby-version file
-
Clone, bundle gems, install some seeds
git clone repo rvm .ruby-version gem install bundle && bundle install
-
Set Postgresql databases omckonrails-dev, omckonrails-test, migrate and seed some data, though seed data is not available at the moment [ source, bash] rake db:setup db:migrate db:seed #optional
-
Set Environment Variables that were listed earlier with creating and editing keys in config/application.yml file
cp config/application.yml.example config/application.yml
-
Run some tests
rspec
-
You are done!
puma
-
Compile Nginx with RTMP module under user nginx with base directory /opt/nginx (this is optional)
mkdir src wget -nc -O src/nginx-1.11.3.tar.gz http://nginx.org/download/nginx-1.11.3.tar.gz wget -nc -O src/v1.1.8.tar.gz https://github.com/arut/nginx-rtmp-module/archive/1.1.8.tar.gz cd src tar xf nginx-1.11.3.tar.gz tar xf v1.1.8.tar.gz cd nginx-$NGINX_VERSION ./configure --add-module=$WORKSPACE/src/nginx-rtmp-module-1.1.8 --prefix=/opt/nginx make make install
-
Edit nginx.conf
user nginx; worker_processes 1; events { worker_connections 1024; } error_log /opt/nginx/logs/error.log warn; pid /opt/nginx/logs/nginx.pid; rtmp { server { listen 1935; chunk_size 4000; application hdgames { live on; notify_method get; on_publish http://authomck:9001/auth; on_publish_done http://authomck:9001/publish_done; allow play all; idle_streams on; hls on; hls_nested on; hls_path /tmp/hls/hdgames; hls_fragment 10s; play_restart on; #RECORD record all; record_path /tmp/rec; record_unique on; on_record_done http://authomck:9001/record_done; #exec ffmpeg -i rtmp://127.0.0.1:1935/$app/$name -acodec copy -c:v libx264 -preset veryfast -profile:v baseline -vsync cfr -s 480x360 -b:v 400k maxrate 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp://127.0.0.1:1935/mobilelive/$; } # MOBILE application mobilelive { allow play all; live on; hls on; hls_nested on; hls_path /tmp/hls/hdgames/mobile; hls_fragment 10s; } # DASH application dashlive { live on; dash on; dash_path /tmp/dash/live; allow play all; } } } http { include /opt/nginx/conf/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; server { listen 8080; location / { root /opt/nginx/html; index index.html; } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /tmp/stat/stat.xsl/; } location /hls { add_header Cache-Control no-cache; add_header Access-Control-Allow-Origin *; types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /tmp; add_header Cache-Control no-cache; } location /dash { add_header Cache-Control no-cache; add_header Access-Control-Allow-Origin *; root /tmp; add_header Cache-Control no-cache; } } }
-
Create directories in /tmp
mkdir -p /tmp/hls/hdgames/mobile mkdir -p /tmp/dash/hdgames/mobile mkdir /tmp/rec mkdir /tmp/stat
-
start nginx
/opt/nginx/sbin/nginx