Stream on-demand media (RTMP)

Tutorial: Stream on-demand media (RTMP)

Prerequisites

To complete this tutorial, install the following software:

Copy on-demand files to Adobe Media Server

Use the vod (video on demand) service on Adobe Media Server to stream recorded media to clients. Simply copy recorded media files to the server and clients can stream them. The vod service streams files to media players from the following two folders:

rootinstall/applications/vod/media

rootinstall/webroot/vod

You can also create subfolders of these folders to hold media files. This tutorial creates a subfolder and copies a file to the subfolder to stream.

  1. Browse to the following folder:

    rootinstall/applications/vod/media

    Note:

    Replace rootinstall with the Adobe Media Server installation folder. For example, on Windows the default installation folder is C:\Program Files\Adobe\Adobe Media Server 5.

  2. Create the folder “tests” in the “media” folder, as follows:

    rootinstall/applications/vod/media/tests

  3. Copy an F4V/MP4 or FLV file to the /tests folder.

    This tutorial uses the following file:

    rootinstall/applications/vod/media/tests/polymorphics.f4v

    If you don’t have a video file, you can download a file from the Moving Images Archive at www.archive.org/details/movies. You can also use a sample file included with the server. For learning purposes, copy a sample file from rootinstall/applications/vod/media to rootinstall/applications/vod/media/tests.

    For information about supported file formats and codecs, see Supported file formats.

Use the Adobe Media Server sample player to play an on-demand file

  1. To open the sample video player in a browser, double-click the rootinstall/samples/videoPlayer/videoplayer.html file.

  2. Enter the address of the video in the STREAM URL textbox, check VOD, and click PLAY STREAM. This tutorial plays the following file:

    rtmp://localhost/vod/mp4:tests/polymorphics.f4v

    If you’re using a Adobe Media Server hosting provider, replace localhost with the domain name or IP address of the server that they provided.

    Note:

    Although you copy the media file to the vod/media folder, you do not need to specify /media in the path when you play the file. The server is configured by default to look for media files in the vod/media folder. If you specify /media in the path, the server looks in the /vod/media/media folder.

    Begin paths to F4V/MP4 files with the prefix mp4:. Use the filename extension of the file, whether it’s F4V, MP4, MOV, and so on.

Use Flash Media Playback to play an on-demand stream

  1. Load the Flash Media Playback Setup page in a web browser.

  2. Enter the Video Source:

    rtmp://localhost/vod/mp4:tests/polymorphics.f4v

    You can replace localhost with the domain name or IP address of the server.

  3. Click Preview to update the embed code.

  4. Click the Play button to test the code.

  5. To use the player in your own HTML page, copy the embed code and paste it into the body of the page. Flash Media Playback is a compiled SWF file hosted by Adobe. For more information, see Play media in Flash Media Playback.

URLs for playing on-demand media files over RTMP

After completing the tutorial once, learn more about how to build a URL that requests a file from the server. Run through the tutorial again using different files and different paths.

The syntax for requesting a file from Adobe Media Server is as follows:

protocol://server-domain-or-IP/ams-app-name/[ams-app-instance-name/][codec-prefix:]file-path[filename-extension]
protocol://server-domain-or-IP/ams-app-name/[ams-app-instance-name/][codec-prefix:]file-path[filename-extension]
protocol://server-domain-or-IP/ams-app-name/[ams-app-instance-name/][codec-prefix:]file-path[filename-extension]

Element

Required

Description

protocol

Yes

The protocol for media delivery. For information about the protocols Adobe Media Server supports, see RTMP, RTMFP, and HTTP in the Technical Overview.

server-domain-or-IP

Yes

The domain name or IP address of the computer hosting Adobe Media Server. If the client is on the same computer as Adobe Media Server, you can use localhost for testing purposes.

ams-app-name

Yes

The Adobe Media Server application that the client connects to. The default folder that holds Adobe Media Server applications is rootinstall/applications. This tutorial uses the application rootinstall/applications/vod.

ams-app-instance-name

No

Applications can have an unlimited number of instances. For example, you could have clients connect to rtmp://localhost/vod/instance1, rtmp://localhost/vod/instance2, and so on.

codec-prefix

Required for F4V/MP4 and MP3 files

The F4V/MP4 and MP3 file formats require a codec prefix in the request URL. For F4V/MP4 files, use the prefix mp4:. For MP3 files, use the prefix mp3:. FLV files do not require a codec prefix.

file-path

Yes

The path from the folder configured to hold media files to the media file. For the vod application, the following folders are configured to hold media files:

rootinstall/applications/vod/media

rootinstall/webroot/vod

In the tutorial, the request URL is: rtmp://localhost/vod/mp4:tests/polymorphics.f4v. The file-path is tests/polymorphics.

If the file polymorphics.f4v were in the /vod/media folder instead of in the /vod/media/tests folder, the full request URL would be rtmp://localhost/vod/mp4:polymorphics.f4v. The file-path would be polymorphics.

Configure the folders to hold media files in the rootinstall/conf/ams.ini file.

filename-extension

Required for F4V/MP4 and MP3 files.

Use the filename extension of the file you want to play. For example, if the file is an F4V file, use .f4v. If the file is an MOV file, use .mov.

Use the following addresses to stream on-demand media files over RTMP:

File format

Address

F4V

rtmp://server-domain-or-IP/vod/mp4:filename

rtmp://server-domain-or-IP/vod/mp4:filename.f4v

rtmp://server-domain-or-IP/vod/mp4:subfolder/fileName.f4v

FLV

rtmp://server-domain-or-IP/vod/filename

rtmp://server-domain-or-IP/vod/filename.flv

To download a file progressively over HTTP from the Apache web server installed with Adobe Media Server, use a standard HTTP address. The following file is in the rootinstall/webroot/vod folder:

http://server-domain-or-IP/vod/filename.xxx

Note:

To use localhost over HTTP, append the port number 8134, for example, http://localhost:8134/vod/video.f4v. The server uses port 8134 internally for HTTP.

Configure the location of media files

Two parameters in the rootinstall/conf/ams.ini file determine the locations of the folders in which the vod application looks for media files:

VOD_COMMON_DIR = C:\Program Files\Adobe\Adobe Media Server 5\webroot\vod
VOD_DIR = C:\Program Files\Adobe\Adobe Media Server 5\applications\vod\media
VOD_COMMON_DIR = C:\Program Files\Adobe\Adobe Media Server 5\webroot\vod VOD_DIR = C:\Program Files\Adobe\Adobe Media Server 5\applications\vod\media
VOD_COMMON_DIR = C:\Program Files\Adobe\Adobe Media Server 5\webroot\vod 
VOD_DIR = C:\Program Files\Adobe\Adobe Media Server 5\applications\vod\media

When a client connects to the vod application and plays a file, the server looks for the file in these two folders.

Files in the folder specified in the VOD_DIR parameter can stream over RTMP only.

Files in the folder specified in the VOD_COMMON_DIR parameter can stream over RTMP and can download progressively over HTTP. Write code in the client that checks for a successful NetConnection to the server over RTMP. If the client doesn’t connect successfully, write code that requests the file over HTTP. The server does not automatically fall back to HTTP.

Note:

Although you copy media to the vod/media folder, do not specify /media in the path when you play the file. The server is configured by default to look for media in the vod/media folder. If you specify /media in the path, the server looks in the /vod/media/media folder.

Change the storage location of media files

  1. Open the rootinstall/conf/ams.ini file in a text editor.

  2. Edit the VOD_DIR and VOD_COMMON_DIR parameters.

  3. Restart Adobe Media Server.

Add new media storage locations

  1. Open the rootinstall/conf/ams.ini file in a text editor.

  2. Add a new parameter and point it to the desired location, for example:

    VOD_DIR_2 = C:\hrvideos
    VOD_DIR_2 = C:\hrvideos
    VOD_DIR_2 = C:\hrvideos
  3. Open the rootinstall/applications/vod/Application.xml file in a text editor.

    The parameters in the ams.ini file are used in the Application.xml configuration file.

    <Application>
    <StreamManager>
    <VirtualDirectory>
    <Streams>/;${VOD_COMMON_DIR}</Streams>
    <Streams>/;${VOD_DIR}</Streams>
    </VirtualDirectory>
    </StreamManager>
    <Application> <StreamManager> <VirtualDirectory> <Streams>/;${VOD_COMMON_DIR}</Streams> <Streams>/;${VOD_DIR}</Streams> </VirtualDirectory> </StreamManager>
    <Application> 
        <StreamManager> 
            <VirtualDirectory> 
                <Streams>/;${VOD_COMMON_DIR}</Streams> 
                <Streams>/;${VOD_DIR}</Streams> 
            </VirtualDirectory> 
        </StreamManager>
  4. Add a <Streams> tag with the new parameter, for example:

    <Streams>/hr;${VOD_DIR_2}</Streams>
    <Streams>/hr;${VOD_DIR_2}</Streams>
    <Streams>/hr;${VOD_DIR_2}</Streams>

    To play streams stored in this folder, use the following address:

    rtmp://localhost/vod/hr/mp4:somefilename.f4v
    rtmp://localhost/vod/hr/mp4:somefilename.f4v
    rtmp://localhost/vod/hr/mp4:somefilename.f4v

    The <Streams> tag tells the server to look for media in the location specified in the VOD_DIR_2 parameter if the media path starts with /hr.

  5. Restart Adobe Media Server.

Duplicate the vod service

The server supports an unlimited number of instances of the vod service.

  1. Duplicate the rootinstall/applications/vod folder in the applications folder and give it a new name, for example, vod2. In this case, the new vod service is located at rootinstall/applications/vod2.

    You can create as many instances of the vod service as you need.

  2. Clients can connect to the vod service at the URL rtmp://adobemediaserver/vod2.

  3. Open the ams.ini file (located in rootinstall/conf) and do the following:

    • Add a parameter to set the content path for the new service, for example: VOD2_DIR = C:\Program Files\Adobe\Adobe Media Server 5\applications\vod2\media.

    • If you installed Apache and want the media files to be available over HTTP, add a new VOD2_COMMON_DIR parameter: VOD2_COMMON_DIR = C:\Program Files\Adobe\Adobe Media Server 5\webroot\vod2.

  4. Open the Application.xml file in the rootinstall/applications/vod2 folder and do the following:

    • Edit the virtual directory to the following: <Streams>/;${VOD2_DIR}</Streams>.

    • Edit the virtual directory to the following: <Streams>/;${VOD2_COMMON_DIR}</Streams>.

  5. Place recorded media files into the following locations:

    • Place files that stream only over RTMP in the C:\Program Files\Adobe\Adobe Media Server 5\applications\vod\media folder.

    • Place files that stream over RTMP or HTTP in the C:\Program Files\Adobe\Adobe Media Server 5\webroot\vod2.

    Note:

    You do not have to specify the media folder in the URL; the media folder is specified in the path you set in the ams.ini file.

Modify server-side code in the vod service

Note:

You cannot modify server-side code in the live service on Adobe Media Server Standard.

  1. Remove the rootinstall/applications/vod/main.far file and replace it with the rootinstall/samples/applications/vod/main.asc file.

Disable the vod service

  1. Move any vod service folders out of the rootinstall/applications folder.

Get help faster and easier

New user?