Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

PeerRails/omck-on-rails

Repository files navigation

Welcome to OmckTV

Peer Rails <peer@omck.ws>

Last updated at 2016.09.25

This page also is available at http://docs.omck.tv/

Test Coverage Status CodeShip Build Status Code Climate Issue Count

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

Development

  1. If You are new to Rails or advanced Rails developer I still will be happy to accept any help

  2. To install please read install guide to set comfortable enviroment for yourself

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

Install Guide

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

  2. Clone, bundle gems, install some seeds

    git clone repo
    rvm .ruby-version
    gem install bundle && bundle install
  3. 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

  4. 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
  5. Run some tests

    rspec
  6. You are done! puma

Advanced setup

  • 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

Contributing

Omck On Rails is 100% free and open source. I encourage an active support and accept contributions from the public – including you!

Clone repo, set environment, make changes, test and pull request.

Thank you!