Video On Demand (VOD) with Red5 Pro

Live streaming options
SHARE

As a developer on the Red5 Pro team and a contributor to the open source project I’ve seen a lot of folks struggle with implementing video on demand experiences using Red5. The reality is it’s really easy. The problem is that it’s just not well documented, so I figured I should write this post to… Continue reading Video On Demand (VOD) with Red5 Pro

As a developer on the Red5 Pro team and a contributor to the open source project I’ve seen a lot of folks struggle with implementing video on demand experiences using Red5. The reality is it’s really easy. The problem is that it’s just not well documented, so I figured I should write this post to give an overview and share some tips and tricks for creating video on demand streaming applications on Red5 Pro. Keep in mind most of what I cover is also directly applicable to the open source version. We’ve also now posted this in our documentation section. So let’s get to it!

– Rajdeep Rath

Here’s what we are going to cover:

WHAT IS VOD?

COMPONENTS OF A VOD SETUP ON RED5 PRO

PREPARING A VIDEO FILE FOR STREAMING

PREPARING RED5 PRO FOR VOD STREAMING

SETTING UP RTMP PLAYER USING JWPLAYER

VOD STREAMING TIPS


WHAT IS VOD?

Video on demand (VOD) is a subscriber paradigm where in users can select a pre-recorded stream to view by their own choice of time and convenience. As opposed to live streaming content, VOD content is stored on the streaming server for on demand consumption. A good example of a VOD system on the internet would be Youtube.com, where millions of users are engaged by rich media content each day.

While different technologies can be to deploy VOD online, we will be concerning ourselves with VOD in the context of Red5 Pro only.


COMPONENTS OF A VOD SETUP ON RED5 PRO

Setting up video on demand using Red5 pro is a very simple and subtle process. To complete the setup successfully you would need a few simple basic components:

1. Media file: A video file encoded in a Red5 pro compatible file format(Explained below). The format and its content codec need to be compliant with the protocol you choose to stream over.

RED5PRO SUPPORTS FOLLOWING THE MEDIA FORMATS COMMONLY FOR STREAMING:

  • Streaming Video (FLV, F4V, MP4)

  • Streaming Audio (MP3, AAC)

2. Red5 Pro media server : A Red5 pro server instance deployed online for serving vod media content to subscribers.

3. Video player: A video player capable of playing your vod stream. To decode media frames being received from the server you will need a compatible video player which understands the protocol that the media is streamed over. Currently Red5 pro supports VOD over RTMP(desktop) and RTSP(mobile) only.

NOTE: No special configuration changes are required to get vod working with Red5 pro. Vod works out of the box with Red5 pro.


PREPARING A VIDEO FILE FOR STREAMING.

Red5 pro supports the following media formats for streaming :

  • Streaming Video (FLV, F4V, MP4, 3GP)

  • Streaming Audio (MP3, F4A, M4A, AAC)

In order for Red5 pro to be able to stream a recorded media to client, it needs to be in a format understood by Red5 pro, supported by the protocol used (RTMP/RTSP) and also readable by the client side player.

A file format is like a container which holds audio and/or video data in a single file. Each file-format in turn allows storing data encoded in specific codecs only. To keep things simple, we wont be venturing into the depth of codecs and encoding here. Let us however take a look at the basic video formats that are compatible with Red5pro and the codecs they support.

Commonly used video formats for VOD transmission :

If your file is not in one of these formats you might need to encode your video for compatibility with Red5pro / flash player using a tool such as Adobe media encoder or the open source ffmpeg encoder.

USEFUL LINKS

https://trac.ffmpeg.org/wiki/EncodingForStreamingSites

https://trac.ffmpeg.org/wiki/Encode/H.264

http://www.avanti.arrozcru.org/ (Windows GUI for FFmpeg executable)


PREPARING RED5 PRO FOR VOD STREAMING

**NOTE: This section assumes that you have already setup Red5 pro on your server successfully.**

Red5 pro does not require any special configuration changes / programming to get vod working. Vod feature works out of the box as long as you use a properly encoded media file for streaming as per the protocol used and have a compatible media player on the client-side to receive and decode the stream.

Red5 pro comes with a pre-installed “vod” application which can be used for streaming video-on-demand content over the internet.

Red5 Pro / webapps directory
Red5 Pro / webapps

To prepare for VOD streaming using Red5 pro do the following steps.

1.   Start Red5 pro server if it is not already running.

2.   Copy your media file into : {red5home} / webapps / vod / streams / directory. If the directory does not exist you will need to create it.

Note: {red5home}: Is the root directory of your red5pro distribution.

VOD Application streams directory VOD Application streams directory

Copying media file into stream directory
Copying media file into stream directory

Red5pro VOD playback is available over RTMP(desktop) and RTSP(mobile) protocols only. If your file is a valid H264 + AAC content then it will be RTSP & RTMP compatible. RTSP is also playable on the desktop using a multi-protocol player such as VLC media player.

3.   You can check out the list of available files in the VOD streams directory by visiting: http://{red5pro-host}:5080/vod/streams.jsp

streams,.jsp output

4.   You can then click on the appropriate protocol link (RTMP / RTSP) for a obtaining a playback url for the platform you wish to target: RTSP your-media-name (for RTSP) or flash your-media-name (for RTMP).

Links Example:

  • RTMP: rtmp://{host}:1935/vod/mp4:trailer.mp4
  • RTSP: rtsp://{host}:8554/vod/trailer.mp4

RTMP is intended for desktop playback and are played in flash based video players that can be embedded in a browser web page. flash although an aging technology is supported on most known types of desktop operating system worldwide.

Flash playback – example (flash trailer.mp4)
Flash playback - example flash trailer.mp4

RTSP is intended for mobile playback only. However, you can always play it on the desktop as well using special players such as vlc media player. This is only for verification only. RTSP links are meant for playback on mobile only.

  1. Copy the RTSP link of the media file from the stream.jsp page.

  2. In VLC media player, select menu => :
    File => Open Network Stream, and paste the rtsp link

  3. Click play

VLC – SETTING PLAYBACK URL
SETTING PLAYBACK URL

VLC – PLAYING STREAM ON RTSP
SETTING PLAYBACK URL

RTSP streams can be played on mobile devices using a mobile based player of your choice, a third party SDK such as JWPlayer SDK, native RTSP playback on android, or the official Red5 Pro SDK.


SETTING UP RTMP PLAYBACK USING JWPLAYER (DESKTOP)

JWPlayer is a standardized and popular video player on the web which supports playback over HTTP, RTMP etc. This session will guide you through setting up Red5 Pro vod streaming using JWPlayer for flash.

1.   Create an account on JWplayer website : https://jwplayer.com/, and login into your account dashboard.

2.   Get your cloud-hosted jwplayer library js link from the dashboard. (Each jwplayer library js is generally an encapsulated player configuration.)

JWplayer Dashboard – Players
JWplayer Dashboard - Player libraries

3.   Create a HTML page with the code snippet shown below. (The js library url must be from your own jwplayer account)

MP4 Streaming

<html><head>  <script src="https://content.jwplatform.com/libraries/V6y49PGY.js"></script></head><body>  <div id="container"></div>  <script>    jwplayer("container").setup({      file: "rtmp://{host}:1935/vod/mp4:trailer.mp4"    });  </script></body></html>

4.   If in case you were using a flv file then your RTMP URL would look different. (see snippet)

FLV Streaming

<html><head>  <script src="https://content.jwplatform.com/libraries/V6y49PGY.js"></script></head><body>  <div id="container"></div>  <script>    jwplayer("container").setup({      file: "rtmp://{host}:1935/vod/trailer.flv"    });  </script></body></html>

5.   If you have set up things correctly so far, loading the url in the browser should now render the player. Clicking on the play button starts stream playback. For other possible player configuration options on jwplayer, you may refer to the extensive jwplayer documentation online.

JWPlayer – Red5 Pro streaming screenshot
JWPlayer - Red5 Pro streaming


VOD STREAMING TIPS

While the information in this document explains the basic setup process for vod streaming using Red5 Pro, there are always a few real world considerations that can be very insightful to a novice Red5pro user. Given below a few points to keep in mind when setting up VOD.

  • Always use a video bitrate that is well below the average bandwidth of your targeted audience.

  • When encoding h264 video / using an already encoded h264 video for mobile playback, keep in mind that the video codec must follow a H264 profile well within your targeted audience’s device capabilities. More Info

  • Avoid using arguably huge video files (in GB) that may overload / clog the server.

  • When using RTSP to achieve native playback, ensure that your android operating system version supports RTSP playback.


trailer.mp4 is from the movie Big Buck Bunny or the associated website, which has been licensed under Creative Commons Attribution 3.0 License according to bigbuckbunny.org.

What kinds of experiences do you want to build with VOD? Is there anything we are missing that would help make your streaming application development easier? Let us know.