Skip to content

Set up the Media Conversion service

Aldo edited this page Apr 24, 2017 · 10 revisions

This section explains how to set up ViSH to provide the Media Conversion service.

  1. Introduction
  2. Installation
  3. Redis
  4. FFmpeg
  5. Resque
  6. God
  7. Enabling
  8. User Interface
  • ViSH has a Media Conversion service which allows to:
    • Convert multimedia files (audio and video) to HTML5 compliant formats. This way, any multimedia file will be displayed directly on the web browser and in all devices.
    • Generate thumbnails for some resources (e.g. videos).

Since the process to convert multimedia files to HTML5 compliant formats takes too long to keep the user waiting, ViSH perform this processing on the background. To do that, ViSH uses Resque for background document processing.
The conversion is done using ffmpeg.

Resque uses the Redis server. It is available as a package for Ubuntu:

sudo apt-get install redis-server

You also need ffmpeg for multimedia conversion. There is also an Ubuntu package available.
Since ffmpeg has been removed from the repositories of the latest Ubuntu versions, you should add one of the repositories offered by http://ffmpeg.org/download.html.

For instance, the following:

sudo add-apt-repository ppa:mc3man/trusty-media

Install ffmpeg:

sudo apt-get install ffmpeg
sudo apt-get install libav-tools

Check ffmpeg version:

$ ffmpeg -version
ffmpeg version git-2017-01-22-f1214ad Copyright (c) 2000-2017 the FFmpeg developers

Resque is a Ruby on Rails gem which is installed by default when doing bundle update since it's included in ViSH.

A worker is a process that perform background jobs such as video or audio conversion. You can find detailed information on the page of the Resque gem.

There is a task rake workers:start, which creates 3 workers for '*' queue. You can customize it by adding some params rake workers:start COUNT=X QUEUE=Y creating X workers for Y queue.

For instance, to launch one worker execute the following command:

$ bundle exec rake workers:start COUNT=1 QUEUE=* 

=== Launching 1 worker(s) on '*' queue(s) with PID 9246

 
You can see the workers' processes through the following command:

$ ps -ef | grep resque

resque-1.23.1: Waiting for *

 
To stop all the active workers use this command:

$ bundle exec rake workers:killall

Killed worker with PID 9246

 

God is a monitoring framework written in Ruby, which is used in ViSH to monitorize, control and keep running the processes of the resque workers. It will restart the workers when any of them goes down, and it will control the amount of memory and resources used by the workers.

To install god:

sudo gem install god

To start the monitoring of the ViSH workers using god:

sudo god -c {vish_folder}/config/resque.god

This script must be execute with sudo. The log is stored in '/tmp/god.log'.

Besides, you can see the traces of the command with the -D option:

sudo god -c {vish_folder}/config/resque.god -D

The root folder of the ViSH application and the environment should be provided as environment variables. If not, the "/u/apps/vish/current" and "production" values respectively are taken by default.
In development you can start god with your current user in the following way:

export RAILS_ROOT="_#{your_folder}_"
export RAILS_ENV="development"
sudo -E god -c config/resque.god -D

To check if god is already running:

$ ps -ef | grep resque.god

sudo -E god -c config/resque.god -D

 

After properly install all the requirements of the Media Conversion service, you should enable the service in the application_config.yml file.

Key Description
services Be sure that the string 'MediaConversion' is included in this array.

Restart the server.

rails s

 

If the Media Conversion service is enabled, you can access the resque user interface at 'http://{ViSH_domain}/resque'. In development this path usually is 'http://localhost:3000/resque'.
Take into account that to access this view, the user must be an administrator.