Video On Demand via Cloudstorage

The use of the Cloudstorage Plugin requires configuration in both the server and in each application utilizing the plugin features. The plugin configuration consolidates the majority of properties required to access cloud storage on Amazon S3 or Google Cloud Platform (GCP). The server configuration must identify the post-processor implementations to use in conjunction with the FLVWriter. An application which will utilize cloud storage for recording and playback has to contain the bean entry for custom file name generator or it will use the Red5 Pro default location.

In order to use AWS or GCP storage you will need to:

  1. Create user credentials on the cloud platform
  2. Create a storage bucket on the cloud platform
  3. Modify the {red5pro}/conf/cloudstorage-plugin.properties file with the credentials and bucket information
  4. Modify the {red5pro}/conf/red5-common.xml file to include the cloud storage post-processor
  5. Modify your webapp's red5-web.xml file to include the cloudstorage post-processor information

AWS S3 Cloud Storage

AWS - Create Security Account

Obtain security credentials for storage account S3 access:

  • Go to the Amazon Identity and Access Management Dashboard
  • From the left-hand navigation, choose Users
  • Click on Add user
  • Enter a User name: (for example, "s3accessuser"); Select AWS Access type Programmatic access; click on Next: Permissions
  • Choose Attach existing policies directly; Search for and choose AmazonS3FullAccess; click on Next: Review
  • Click Create user
  • Click Show under Secret access key to reveal the key generated. It is critical that you make a note of this, as you will not be able to retrieve it from the AWS console after you close the creation screen.
  • Click “download Credentials” button to download a csv file with the credentials to your computer. You will not have this option again, so keep this file in a safe place!
  • Click “close” to close the window and return to IAM Users screen.
  • You should be able to see the user you recently created - “s3accessuser” in the list on the page.

Set up an S3 Storage Bucket to be Used for VOD

Navigate to S3 Storage on AWS.

Click on the Create Bucket button.

Enter a bucket name and choose the region you wish it to be hosted in. (Note: bucket names must contain only lowercase characters. Also the bucket name cannot include any periods (.) or spaces, otherwise the playback feature will fail). The click on Create. Also note - at this time, buckets must be in either US or Asian regions. EU regions are not supported. No additional permissions need to be set.

createbucket

Google Cloud Platform (GCP) Storage

GCP - Create Security Account

GCP allows using AWS style credentials specifically in the Interoperability mode for seamless migration or interoperability. This allows AWS S3 libraries to use GCP storage transparently. To be able to use this feature you need to enable Interoperability Access for your Google cloud storage.

Obtain interoperable keys for GCP storage authentication

GCP Storage Settings

  • If you haven't enabled it already, click on "Interoperable Access"
  • Now you should see an empty list and a "Create new Key" button
  • Click on the button in order to create an access/secret keypair

NOTE: These keys are associated with the account that you use to log into GCP, not to the Google project.

Set up a GCP Storage Bucket to be Used for VOD

Select your project & navigate to Storage in GCP console.

  • Select Browser from the left-hand pane
  • Click on Create Bucket to bring up the bucket creation UI
    • Enter a bucket name for your bucket
    • Set storage class to Multi-Regional or Regional (Other storage classes are not currently supported)
    • If you choose Multi-Regional, select appropriate location from the dropdown list and if choosing Regional, select an appropriate region.

createbucket

Install Red5 Pro Server

Following these instructions, install the Red5 Pro Server.

Modify Cloudstorage Plugin Properties File

Edit the {red5pro}/conf/cloudstorage-plugin.properties file:

# Cloudstorage Plugin Properties
#
# JetS3t library configuration option info: http://jets3t.s3.amazonaws.com/toolkit/configuration.html
#

# Plugin Services
services=
# for AWS S3 cloudstorage
#services=com.red5pro.media.storage.s3.S3Uploader,com.red5pro.media.storage.s3.S3BucketLister
# for Google Cloud storage
#services=com.red5pro.media.storage.gstorage.GStorageUploader,com.red5pro.media.storage.gstorage.GStorageBucketLister
# Path
# Path
streams.dir=/tmp/
# Full path to the ffmpeg executable
ffmpeg.path=/usr/bin/ffmpeg

# Time
max.transcode.minutes=5

# FFMpeg command line for transcoding flv to mp4
## add the '-report' parameter after '-y' to get a log for debugging if problems occur
## Variables: 0=replaced with ffmpeg path, 1=input file path, 2=output file path

### LGPL command template
#ffmpeg.template=%s -y -async 1 -i %s -acodec aac -b:a 128k -ar 44100 -strict -2 -vcodec libopenh264 -pix_fmt yuv420p -profile:v baseline -level 3.0 %s

### GPL command template
ffmpeg.template=%s -y -async 1 -i %s -acodec aac -b:a 128k -ar 44100 -strict -2 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 %s

# AWS Configuration
aws.access.key=YOUR_AWS_ACCESS_KEY
aws.secret.access.key=YOUR_AWS_SECRET_ACCESS_KEY
# Bucket name
aws.bucket.name=red5provod
# Valid locations are: US for United States, EU for Europe, and AS for Asia
aws.bucket.location=US

# Google Storage Configuration
gs.access.key=YOUR_GOOGLE_STORAGE_ACCESS_KEY
gs.secret.access.key=YOUR_GOOGLE_STORAGE_SECRET_ACCESS_KEY
# Bucket name
gs.bucket.name=red5provod

Cloudstorage Plugin Properties - AWS

Plugin Properties to modify

  • services = make sure that the following are included: com.red5pro.media.storage.s3.S3Uploader,com.red5pro.media.storage.s3.S3BucketLister
  • streams.dir = The base directory from which read from and recorded to. A streams application / scopes are appended to this path.
  • aws.access.key = Your AWS access key.
  • aws.secret.access.key = Your AWS secret access key.
  • aws.bucket.name = The S3 bucket in which files will be stored.
  • aws.bucket.location = Geographic location of the S3 bucket.
  • ffmpeg.path = Full path to the FFMpeg executable (for orientation post-processor only).
  • max.transcode.minutes = Maximum time in minutes allotted for transcoding to run per file.

Cloudstorage Plugin Properties - GCP

Plugin Properties to modify

  • services = make sure that the following are included: com.red5pro.media.storage.gstorage.GStorageUploader, com.red5pro.media.storage.gstorage.GStorageLister
  • gs.access.key = Your Google storage access key
  • gs.secret.access.key = Your Google storage secret access key
  • gs.bucket.name = The GCP storage bucket in which files will be stored.
  • ffmpeg.path = Full path to the FFMpeg executable (for orientation post-processor only).
  • max.transcode.minutes = Maximum time in minutes allotted for transcoding to run per file.

Server Configuration

The writer post processors used by FLVWriter are configured in the server's common configuration file: conf/red5-common.xml. The example below displays the configuration with the S3 post-processors (note - this bean exists in the file, you just need to modify & add the writer post processors value):

Post Processor For AWS S3

<bean id="flv.impl" class="org.red5.io.flv.impl.FLV">
  <property name="cache">
    <ref bean="object.cache"/>

  </property>
  <property name="writerPostProcessors">
    <set>
      <value>com.red5pro.media.processor.S3UploaderPostProcessor</value>
    </set>
  </property>

</bean>

The S3UploaderPostProcessor uploads a supplied FLV file to an S3 bucket with a public read ACL and mime type of video/x-flv. For example, a stream named stream1471289267434 recorded to the application live using a bucket named red5-s3 would be made available at https://s3.amazonaws.com/red5-s3/live/streams/stream1471289267434.flv after the upload is completed. The HLS files, one stream1471289267434.m3u8 and several stream1471289267434_#.ts files would be found in https://s3.amazonaws.com/red5-s3/live/stream1471289267434

Post Processor For GCP Storage

<bean id="flv.impl" class="org.red5.io.flv.impl.FLV">
  <property name="cache">
    <ref bean="object.cache"/>

  </property>
  <property name="writerPostProcessors">
    <set>
      <value>com.red5pro.media.processor.GStorageUploaderPostProcessor</value>
    </set>
  </property>

</bean>

The GStorageUploaderPostProcessor uploads a supplied FLV file to a GCP storage with a public read ACL and mime type of video/x-flv. For example, a stream named stream1471289267434 recorded to the application live using a bucket named red5-gcp would be made available at https://storage.cloud.google.com/red5-gcp/live/streams/stream1471289267434.flv after the upload is completed. The HLS files, one stream1471289267434.m3u8 and several stream1471289267434_#.ts files would be found in https://storage.cloud.google.com/red5-gcp/live/stream1471289267434

Application Configuration

Every server application that will utilize cloudstorage for storage must have its configuration file modified to use the FilenameGenerator features. The live webapp (red5pro)/webapps/live/WEB-INF/red5-web.xml includes a line for each cloud platform, which can be un-commented. Red5 Pro server applications use the streamFilenameGenerator bean when specified for locating media files for Playback or Recording; if the bean is not specified in an applications red5-web.xml, the default generator will be used which plays from and records to the application's streams directory.

For AWS S3

    <!-- Enable this if you're using S3 storage -->

    <bean id="streamFilenameGenerator" class="com.red5pro.media.storage.s3.S3FilenameGenerator"/>

For GCP Storage

    <!-- Enable this if you're using GCP storage -->

<bean id="streamFilenameGenerator" class="com.red5pro.media.storage.gstorage.GStorageFilenameGenerator"/>