Skip to content
/ CW-OVP Public

video packaging to *.m3u8 for HLS (HTTP Live Streaming) with FFMPEG on website (ruby on rails)

License

Notifications You must be signed in to change notification settings

x1wins/CW-OVP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

CW-OVP

Preview

show
index

Introduction

EN

OVP(online video platform) mean that online transcoding, packaging and hosting service with video file upload to online storage or cloud system.
Internet speed was increase and many internet user prefer to streaming service for Mobile, web, OTT than service from over-the-air television networks. but streaming service use OVP or solution for start streaming service with Mobile, web, OTT(over the top). such as OVP and some solution require many spend money for streaming service.
Famous OVP business company is brightcove.com, mux.com, dacast.com, vimeo.com, Dacast.com, Amazon elastic transcoding and Wowza solution.
CW-OVP project will commit helping for who want ready for streaming service.
This is why CW-OVP project was built.

KO

OVP(online video platform)란
온라인 저장소 또는 클라우드에 비디오 파일을 업로드하여 트랜스코딩과 페키징 처리후 호스팅 서비스를 제공함을 말한다.
인터넷 속도의 발달과 사용자들의 요구로 많은 스트리밍 서비스가 생겨나고 있고, 기존의 방송사들도 흐름에 따라 Mobile, web, OTT(over the top) 셋탑기기의 스트리밍 서비스를 제공하기 위해서 OVP(online video platform)이나 솔류션을 많이 사용하고 있다.
대표적인 해외 OVP는 brightcove.com, mux.com, dacast.com, vimeo.com, Dacast.com, Amazon elastic transcoding 등 서비스들이 존재하며 솔류션으로는 Wowza가 존재한다.
이에 CW-OVP 프로젝트를 오픈소스로 개발하여 기업이나 단체, 개인에 도움이 되고자 한다.

Tech Stack

what use description
FFMPEG video transcoding, packaging
h.264 Codec
HLS Protocol
Ruby on Rails web framework, websocket(action cable)
Redis queue, pub/sub
Sidekiq background job, queue
Postresql database
Docker, docker-compose install environment
Docker Swarm Clustering
Kubernetes Clustering
  • you can choose Docker swarm or Kubernetes(kops or EKS) for Clustering

Feature

  • Clustering ffmpeg worker with sidekiq on Docker swarm or Kubernetes
  • Transcoding, Packaging with ffmpeg for HLS
    • Generated multiple m3u8 for Adaptive Streaming
  • Extract 10 random Thumbnail images during video packaging
  • AWS S3 for stored video, thumbnail assets
  • AWS Cloudfront for CDN
  • Real time base on web UI with websocket(Action Cable), ruby on rails
  • Open source (GPL-2.0 License) and Free, but need hardware…

System Structure

cw-ovp-system-structure.png

  • If your node for database that got fault or something wrong, You can lost persistent in database. that's why I recommend AWS RDS for postgresql.

Getting started

Storage config

How To Run Development mode with Docker-compose

  1. Download source
    1. git clone https://github.com/x1wins/CW-OVP.git
    2. cd ./CW-OVP
  2. Build and Run
    1. docker-compose --env-file .env.dev.s3 up --build -d
    2. docker-compose run --no-deps web bundle exec rails webpacker:install
    3. docker-compose --env-file .env.dev.s3 restart web
    4. docker-compose run --no-deps web bundle exec rake db:create
    5. docker-compose run --no-deps web bundle exec rake db:migrate
    6. docker-compose run --no-deps web bundle exec rake db:create RAILS_ENV=test
    7. docker-compose run --no-deps web bundle exec rake db:migrate RAILS_ENV=test
  3. Restart for updated code
    1. git fetch origin develop
    2. git reset --hard origin/develop
    3. Restart web, sidekiq
      docker-compose --env-file .env.dev.s3 restart web
      docker-compose --env-file .env.dev.s3 restart sidekiq
      
  4. Unit testing with rspec
    docker-compose run --no-deps web bundle exec rspec --format documentation
    
  5. Console
    docker-compose run --no-deps web bundle exec rails console
    
  6. Troubleshooting
    1. when I got bundle error such as minemagic
      1. Log of minemagic gem error
        Step 10/16 : RUN bundle install
        ---> Running in 578d62fab6ac
        Fetching gem metadata from https://rubygems.org/............
        You have requested:
         mimemagic ~> 0.4.1
        The bundle currently has mimemagic locked at 0.3.5.
        Try running `bundle update mimemagic`
        If you are updating multiple gems in your Gemfile at once,
        try passing them all to `bundle update`
        ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 7
        The command "docker-compose build" failed and exited with 1 during .
        Your build has been stopped.
        
      2. Solution
        docker-compose run --no-deps web bundle update mimemagic
        
    2. Keep latest gem for defense vulnerability
      docker-compose run --no-deps web bundle update
      docker-compose run --no-deps web yarn upgrade --latest
      
    3. no space left on device
      1. https://www.changwoo.org/x1wins@changwoo.net/2021-02-12/write-myapp-tmp-redis-appendonly-aof-9ff1127366
      2. Log
        % docker-compose --env-file .env.dev.s3 up --build
        Building web
        Step 1/16 : FROM ruby:2.6.3
         ---> 8fe6e1f7b421
        Step 2/16 : RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - &&     curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&     echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&     apt-get update &&     apt-get install -qq -y build-essential nodejs yarn vim     libpq-dev postgresql-client ffmpeg
         ---> Using cache
         ---> 14eb2f07d9e5
        Step 3/16 : RUN apt-get update &&     apt-get install -y         python3         python3-pip         python3-setuptools         groff         less     && pip3 install --upgrade pip     && apt-get clean
         ---> Using cache
         ---> c57e46926299
        Step 4/16 : RUN pip3 --no-cache-dir install --upgrade awscli
         ---> Using cache
         ---> 7e8e641bfc90
        Step 5/16 : RUN mkdir /myapp
         ---> Using cache
         ---> a0a39c82945a
        Step 6/16 : RUN mkdir /storage
         ---> Using cache
         ---> 66348ad31ef0
        Step 7/16 : WORKDIR /myapp
         ---> Using cache
         ---> 47b601075951
        Step 8/16 : COPY . /myapp
        ERROR: Service 'web' failed to build : Error processing tar file(exit status 1): write /myapp/tmp/storage/og/op/ogopd3w9xnrwq0b6kqf8beh726xu: no space left on device
        
      3. Solution
        % docker system prune
        WARNING! This will remove:
          - all stopped containers
          - all networks not used by at least one container
          - all dangling images
          - all dangling build cache
        
        Are you sure you want to continue? [y/N] y
        

How To Run Development mode without docker

SETUP_WITHOUT_DOCKER.md

Sample video file download

Minimum Requirements for Production

  • Required AWS S3 for Storage
  • Required AWS Cloudfront for CDN
  • Server Spec
    • CPU
      • 8 or more Cpu per server (c5.2xlarge on aws ec2)
    • Disk
      • more 10 Gb
      • if you will upload heavy video or more 10Gb, need more space
    • Memory
      • more 2Gb
    • Number of Server
      • master : 1 or more
      • slave : 2 or more

Roadmap

Roadmap

Deploy

kubernetes

K8s with kops for Production

Docker Swarm

DOCKER-SWARM.md

Webhook

Webhook