Stream live media (HTTP) -- using FMS

http://help.adobe.com/en_US/flashmediaserver/devguide/WSd391de4d9c7bd609-52e437a812a3725dfa0-8000.html


Prerequisites for live streaming over HTTP

To use HTTP Dynamic Streaming (HDS) and HTTP Live Streaming (HLS) to serve live streams to clients over HTTP, publish the streams to the HTTP Live Packager service on Flash Media Server (rootinstall/applications/livepkgr). The livepkgr service ingests the streams, packages them into fragments, and delivers the fragments to Flash and iOS clients in real-time.

To complete these tutorials, use the following software:

  • Flash Media Server 4.5. See the video Install Flash Media Server 4.5 and verify HTTP streaming to Flash and iOS.

  • Flash Media Live Encoder

    Note: Flash Media Live Encoder on Windows doesn’t support AAC encoding. To add support for AAC, purchase the  MainConcept AAC Encoder.
  • (Adobe HTTP Dynamic Streaming) Flash Media Server sample video player (which uses Strobe Media Playback) and Flash Player 10.1.

  • (Apple HTTP Live Streaming) iOS 3.0 or later device or Mac OS 10.6 with Safari 4.0 or QuickTime X.

For more information, see Supported clients, encoders, codecs, and file formats and Pre-built media players.

Publish and play a single live stream over HTTP

  1. Install Flash Media Server 4.5 and choose to install Apache HTTP Server.

  2. Install Flash Media Live Encoder and configure it to use absolute time.

    1. Close Flash Media Live Encoder.

    2. Open the Flash Media Live Encoder rootinstall\conf\config.xml file in a text editor.

      The default installation location on Windows is C:\Program Files\Adobe\Flash Media Live Encoder 3.2.

      The default installation location on Mac OS is Macintosh HD:Applications:Adobe:Flash Media Live Encoder 3.2.

    3. Set the tag //flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable to true:

       
           
               
                   
                  true
    4. Save the file.

  3. To publish a live stream to Flash Media Server, start Flash Media Live Encoder and do the following:

    1. In the Encoding Options panel, from the Preset pop-up menu, choose High Bandwidth (800 Kbps) — H.264. For Audio Format, choose AAC.

      Note: Flash Media Live Encoder on Windows doesn’t support AAC encoding. To add support for AAC, purchase the  MainConcept AAC Encoder.
      View full size graphic
      Flash Media Live Encoder Encoding Options panel
    2. Click the wrench next to Format to open Advanced Encoder Settings and do the following:

      • Profile—Main

      • Level—3.1

      • Keyframe Frequency—4 or a multiple of  in the applications/livepkgr/events/_definst_/liveevent/Event.xml file. The default value of is 4000 milliseconds.

        Note: For information about profile and level support, see  Supported file formats and codecs.
        Flash Media Live Encoder Advanced Encoder Settings
    3. In the FMS URL text box enter the following:

      rtmp://localhost/livepkgr
      Note: Use the RTMP protocol to stream the content to the livepkgr application on Flash Media Server. You can substitute an IP address or a domain name for “localhost”.
    4. In the Stream text box enter the following:

      livestream?adbe-live-event=liveevent
      Note: The applications/livepkgr/main.asc file expects this value.
    5. Deselect Save to File.

    6. Click Start.

  4. (Adobe HTTP Dynamic Streaming) To play the media in Flash Media Playback, do the following:

    1. Open Flash Media Playback in a web browser:

      http://www.osmf.org/configurator/fmp/

    2. Note: Flash Media Playback requires Flash Player 10.1 to support HTTP Dynamic Streaming.
    3. In Video Source, enter:

      http://localhost/hds-live/livepkgr/_definst_/liveevent/livestream.f4m

      For information about the request URL, see URLs for publishing and playing live streams over HTTP.

    4. Select Yes under the question “Are you using HTTP Streaming or Flash Access 2.0?”.

    5. Click Preview. Click Play.

    View full size graphic
    HDS live stream playing in Flash Media Playback
  5. (Adobe HTTP Dynamic Streaming) To play the media in Strobe Media Playback, do the following:

    1. Open the Flash Media Server sample video player in a web browser. Browse to rootinstall/samples/videoPlayer/videoplayer.html

    2. In STREAM URL, enter:

      http://localhost/hds-live/livepkgr/_definst_/liveevent/livestream.f4m

      For information about the request URL, see URLs for publishing and playing live streams over HTTP.

    3. Select LIVE and Click PLAY STREAM.

    View full size graphic
    HDS live stream playing in the Flash Media Server sample video player
  6. (Apple HTTP Live Streaming) Use the following URL:

    http://10.0.1.11/hls-live/livepkgr/_definst_/liveevent/livestream.m3u8

    View full size graphic
    HLS live stream playing in Safari on an iPad

    For information about where to use the URL to serve various iOS devices, QuickTime, and Safari, see HTTP Live Streaming Overview in the iOS Reference Library.

    For information about the request URL, see URLs for publishing and playing live streams over HTTP.

Note: Replace “localhost” or “10.0.1.11” with the domain name or IP address of the computer hosting Flash Media Server. If you’re using a Flash Media Server hosting provider, they can give you this value.

Publish and play live multi-bitrate streams over HTTP

  1. Install Flash Media Server 4.5 and choose to install Apache HTTP Server.

  2. Install Flash Media Live Encoder and configure it to use absolute time.

    1. Close Flash Media Live Encoder.

    2. Open the Flash Media Live Encoder rootinstall\Conf\config.xml file in a text editor.

    3. Set the tag //flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable to true:

       
           
               
                   
                  true
    4. Save the file.

  3. Browse to rootinstall/applications/livepkgr/events/_definst_/liveevent and do the following:

    • Edit the Event.xml file to look like the following:

       
          liveevent 
               
                      4000 
                      16000 
                      3 
               
       
    • Remove the Manifest.xml file from the liveevent folder or rename it.

  4. (Adobe HTTP Dyanmic Streaming) For multi-bitrate streaming, Flash and AIR media players request an F4M manifest file that contains the location and bitrate of each live stream. This type of F4M file is called a set-level manifest. To create an set-level manifest, do the following:

    1. Open rootinstall/tools/f4mconfig/configurator/f4mconfig.html in a browser.

    2. Select the f4m file type.

    3. Stream URIs can be absolute or relative to a Base URI. Enter the following for the Base URI:

      http://localhost/hds-live/livepkgr/_definst_/liveevent

    4. Enter the following for each stream and click Add:

      Stream URI

      Bitrate

      livestream1.f4m

      150

      livestream2.f4m

      500

      livestream3.f4m

      700

      View full size graphic
      Set-level F4M file in the Set-level F4M/M3U8 File Generator
    5. To preview the file, click View Manifest. The manifest file looks like this:

       
          http://localhost/hds-live/livepkgr/_definst_/liveevent/ 
           
           
           
      
    6. Click Save Manifest and save the file as liveevent.f4m to rootinstall/webroot.

      The media player requests this file from a web server. This tutorial saves the file to rootinstall/webroot, but the file can be served from any location on any webserver. This file does not need to live on Flash Media Server. This file can also have any name.

  5. (Apple HTTP Live Streaming) iOS devices request an M3U8 variant playlist file that contains the location, bitrate, and optionally the codec of each stream. To create an M3U8 file, do the following:

    1. If the Set-level F4M/M3U8 File Generator tool isn’t open, double-click rootinstall/tools/f4mconfig/configurator/f4mconfig.html to open it in a browser.

    2. Select m3u8.

    3. Enter the Stream URI and bitrate for each stream. Stream URIs can be absolute or relative. If they are relative, they are relative to the m3u8 file.

      Note: You can’t use a Base URI when generating an M3U8 file.

      This tutorial uses the following Stream URI settings:

      Stream URI

      Bitrate

      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream1.m3u8

      150

      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream2.m3u8

      500

      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream3.m3u8

      700

      View full size graphic
      Set-level M3U8 file in the Set-level F4M/M3U8 File Generator
    4. For m3u8 files, you can optionally add a codec for each stream.

      If one stream is audio-only, specify an audio codec. Specify audio and video codecs for the other streams in the manifest. See Publish an audio-only stream (HLS).

    5. To view the file, click View Manifest. The m3u8 file looks like this:

      #EXTM3U 
      #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=150000 
      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream1.m3u8 
      #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=500000 
      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream2.m3u8 
      #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=700000 
      http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream3.m3u8
    6. Save the file as liveevent.m3u8 to the folder rootinstall/webroot.

      The media player requests this file from a web server. This tutorial saves the file to rootinstall/webroot, but the file can be served from any location on any webserver. This file does not need to live on Flash Media Server.

  6. To publish a live stream to Flash Media Server, start Flash Media Live Encoder and do the following:

    1. In the Encoding Options panel, from the Preset pop-up menu, choose Multi Bitrate - 3 Streams (1500 Kbps) - H.264. Choose Audio Format AAC.

      Note: Flash Media Live Encoder on Windows doesn’t support AAC encoding. To add support for AAC, purchase the  MainConcept AAC Encoder.
    2. Click the wrench next to Format to open Advanced Encoder Settings. For Keyframe frequency, select 4 seconds.

      Note: This value matches the   value in the applications/livepkgr/events/_definst_/liveevent/Event.xml file. The   value is in milliseconds.
    3. For Bit Rate, choose 150, 500, and 700.

    4. In the FMS URL text box, enter the following:

      rtmp://localhost/livepkgr
      Note: This application is installed with Flash Media Server and contains a main.asc file and configuration files for live HTTP Dynamic Streaming.
    5. In the Stream text box, enter the following:

      livestream%i?adbe-live-event=liveevent
      Note: The applications/livepkgr/main.asc file expects this value. Flash Media Live Encoder uses the variable %i to create multiple stream names: livestream1, livestream2, livestream3, and so on. To use another encoder, provide your own unique stream names, for example,  livestream1?adbe-live-event=liveeventlivestream2?adbe-live-event=liveevent.
    6. Deselect Save to File.

    7. Click Start.

  7. (Adobe HTTP Dynamic Streaming) Flash Media Playback does not support set-level manifest files. To play the media, use Strobe Media Playback. Strobe Media Playback is used in the sample video player that installs with Flash Media Server.

    1. Copy the videoPlayer directory from rootinstall/samples/videoPlayer to rootinstall/webroot.

    2. Browse to the sample player in a web browser:

      http://localhost/videoPlayer/videoplayer.html

    3. In Video Source, enter the following:

      http://localhost/liveevent.f4m

  8. (Apple HTTP Live Streaming) In iOS, enter the following URL in Safari:

    http://localhost/liveevent.m3u8

    For information about where to use the URL to serve various iOS devices, QuickTime, and Safari, see HTTP Live Streaming Overview in the iOS Reference Library.

Note: You can replace localhost with the domain name or IP address of the computer hosting Flash Media Server. If you’re using a Flash Media Server hosting provider, they can give you this value.

See also

Configure protected HTTP Dynamic Streaming (PHDS)

Configure protected HTTP Live Streaming (PHLS)

Configure set-level F4M/M3U8 files for multi-bitrate streaming

Publish an audio-only stream (HLS)

To serve streams over a cellular network, one of the streams must be audio-only. For more information, see HTTP Live Streaming Overview.

To publish an audio-only stream, enter the following in the Flash Media Encoder Stream field:

livestream%i?adbe-live-event=liveevent&adbe-audio-stream-name=livestream1_audio_only&adbe-audio-stream-src=livestream1

If the encoder specifies individual query strings for each stream, use individual stream names instead of the variable %i:

livestream1?adbe-live-event=liveevent&adbe-audio-stream-name=livestream1_audio_only

livestream2?adbe-live-event=liveevent&adbe-audio-stream-name=livestream2_audio_only

Note: You can use the values in italics or replace them with your own values. The default live event is called “liveevent”.

Parameter

Description

adbe-audio-stream-name

The name of the audio-only stream.

adbe-audio-stream-src

The name of the stream from which to extract the audio for the audio-only stream. If this parameter is not specified, the server uses the stream on which theadbe-audio-stream-name parameter was specified.

To generate a set-level variant playlist when using an audio-only stream, specify the audio codec of the audio-only stream. Specify the audio and the video codec of the streams that contain audio and video. For more information about using the Set-level F4M/M3U8 File Generator, see Publish and play live multi-bitrate streams over HTTP.

URLs for publishing and playing live streams over HTTP

Important: The format for HDS request URLs has changed in Flash Media Server 4.5. The Apache httpd.conf file redirects requests in the 4.0 format to the 4.5 format. The path /live/events/livepkgr/events redirects to the path /hds-live/livepkgr.

Use the following URL to publish a single live stream to Flash Media Server for streaming over HTTP:

rtmp://fms-ip-or-dns/livepkgr/livestream?adbe-live-event=liveevent

Use the following URL to publish multiple live streams to Flash Media Server for adaptive bitrate streaming:

rtmp://fms-ip-or-dns/livepkgr/livestream%i?adbe-live-event=liveevent

Note: Publish the stream over RTMP. Clients play the stream over HTTP.

Use the following URLs to play live streams over HTTP:

Client

Single stream or Adaptive Bitrate

Request URL

Adobe HDS

Single stream

http:///hds-live/livepkgr///.f4m

Apple HLS

Single stream

http:///hls-live/livepkgr///.m3u8

Adobe HDS

Adaptive bitrate

The media player requests a set-level manifest file:

http:///.f4m

The set-level manifest file contains URLs for each live stream in the following format:

http:///hds-live/livepkgr///.f4m

Apple HLS

Adaptive bitrate

The media player requests a set-level variant playlist file:

http:///.m3u8

The set-level variant playlist contains URLs for each live stream in the following format:

http:///hls-live/livepkgr///.m3u8

Important: To play streaming media over HTTP, a media player requests a manifest file (F4M or M3U8). The server generates manifest files in real-time. The files are not written to disk; you cannot see them on the server.

The path /hds-live is a  directive in the Apache httpd.conf file that tells the server to package the content for Adobe HTTP Dynamic Streaming (HDS).

The path /hls-live is a  directive in the Apache httpd.conf file that tells the server to package the content for Apple HTTP Live Streaming (HLS).

For adaptive streaming, the client requests a set-level manifest. For HDS, this file is a .f4m file. For HLS, this file is a .m3u8 file. The set-level manifest can live on any web server. You can create multiple set-level manifest files for a single set of live streams.

The set-level manifest contains the paths to the F4M manifest files (HDS) and M3U8 variant playlists (HLS) of each live stream. The paths must begin with /hds-live or /hls-live to tell the server to package the streams for HTTP.

Note: Do not include /hds-live or /hls-live in the URL that requests the set-level manifest.

You can configure the  directive settings and the content location in the Apache httpd.conf file. For more information, see Content storage (HDS and HLS).

Differences in HTTP live URLs from Flash Media Server 4.0 to Flash Media Server 4.5

The default URL to play a live stream over HTTP has changed in Flash Media Server 4.5. In Flash Media Server 4.0, the URL to play a live stream was http:///live/events/livepkgr/events/. The Flash Media Server 4.5 Apache httpd.conf file uses a 301 redirect to redirect requests that use a 4.0 URL to the 4.5 URL.

For more differences, see Differences in HTTP Dynamic Streaming between Flash Media Server 4.0 and 4.5.

Configure DVR (HDS)

Configure DVR on the server

  1. Open the Set-level F4M/M3U8 File Generator in a browser: rootinstall/tools/f4mconfig/configurator/f4mconfig.html.

  2. In addition to entering values for Stream URI and Bitrate, enter a value for DVR Window Duration. This value sets the amount of viewable content, in minutes, before the live point.

    Use the following guidelines to set a Window Duration:

    • Set Window Duration to a value greater than 0.

      Setting the Window Duration to 0 can cause a bad user experience.

    • A value of -1 indicates that the available recorded content behind the live point is unlimited.

  3. In the Event.xml file, configure the DiskManagementDuration element to specify the amount of content the server caches. By default, the server caches 3 hours of content. Use the following formula to determine the value of the Window Duration in relation to the value of DiskManagementDuration:

    HDSWindowDuration <= (DiskManagementDuration - SegmentDuration)

    For more information about disk managment, see Disk management.

Publish a DVR stream

To publish a DVR stream from Flash Media Live Encoder, do not click Record or check DVR Auto Record. Publish the stream just as you publish any live stream.

Play DVR streams

Strobe Media Playback supports DVR streams by default.

Note: Flash Media Playback does not support set-level manifest files. To use Flash Media Playback, configure a Manifest.xml file. See  Manifest.xml.

Configure a sliding window (HLS)

Configure a sliding window on the server

sliding window is the seekable portion of the stream for Apple HTTP Live Streaming. Clients cannot seek beyond the sliding window length. HTTP Live Streaming clients use the sliding window to configure the seek bar.

Configure a sliding window at the following levels:

Level

Configuration file

Server

rootinstall/Apache2.2/conf/httpd.conf

Application

rootinstall/applications/livepkgr/Application.xml

The livepkgr application is the default application for HTTP streaming. You can duplicate and rename this application.

Event

rootinstall/applications/livepkgr/events/_definst_/liveevent/Event.xml

The liveevent folder is the default live event. You can create multiple live events within an application.

Use the following parameters:

Parameter

Configuration file

Description

HLSSlidingWindowLength

httpd.conf

The number of TS files available for seeking in a sliding window.

SlidingWindowLength

Application.xml and Event.xml

The number of TS files available for seeking in a sliding window.

HLSMediaFileDuration

httpd.conf

The length of a TS file, in milliseconds.

MediaFileDuration

Application.xml and Event.xml

The length of a TS file, in milliseconds.

The time within the sliding window is:

HLSSlidingWindowLength * HLSMediaFileDuration 
SlidingWindowLength * MediaFileDuration

By default, HLSSlidingWindowLength is set to 6 seconds and HLSMediaFileDuration is set to 8000 milliseconds. Therefore, by default, all HLS live events are seekable within a window that is 48 seconds wide.

The sliding window is relative to the current position of the live stream. For example, if sliding window is configured to have 15 minutes of data and the event starts at time 0, when the live stream is at 30, the last seek position possible is 15.

To make an entire live event seekable, set SlidingWindowLength or HLSSlidingWindowLength to 0. However, doing so may impact performance.

Configure the sliding window to be smaller than the duration of content cached on disk. In the Event.xml file, the DiskManagementDuration element specifies the amount of content the server caches. By default, the server caches 3 hours of content. The size of the HLS sliding window must be as follows:

HLSSlidingWindow <= (DiskManagementDuration - SegmentDuration)

For more information about disk managment, see Disk management.

Configure a sliding window at the event level

The following Event.xml file creates a 1 hour sliding window for a single HLS live event:

 
    liveevent 
     
        4000 
        400000 
        3 
     
     
        8000 
        450 
     

Configure a sliding window at the application level

The following Application.xml file creates a 1 hour sliding window for all HLS live events within the livepkgr application:

 
     
         
            true 
         
     
     
        8000 
        450 
     

Reload the livepkgr application.

Configure a sliding window at the server level

The following Apache configuration sets HLSSlidingWindowLength to 450. This configuraiton creates a 1 hour sliding window for all HLS live events on the server:

... 
 
 
    HLSHttpStreamingEnabled true 
    HttpStreamingLiveEventPath "../applications" 
    HttpStreamingContentPath "../applications" 
    HLSMediaFileDuration 8000 
    HLSSlidingWindowLength 450 
    HLSFmsDirPath ".." 
    HLSM3U8MaxAge 2 
    HLSTSSegmentMaxAge -1 
    Options -Indexes FollowSymLinks 

Restart Apache HTTP Server.

Publish streams with a sliding window

You don’t need to configure any encoder settings to publish a stream with a sliding window.

Play streams with a sliding window

Devices that support HTTP Live Streaming support the sliding window feature by default.

Duplicate the livepkgr service

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

 Duplicate the rootinstall/applications/livepkgr folder in the applications folder and give it a new name, for example, livepkgr2. In this case, the new livepkgr service is located atrootinstall/applications/livepkgr2.

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

Modify server-side code in the livepkgr service

Note: You cannot modify server-side code on Flash Media Streaming Server.

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

你可能感兴趣的:(Stream live media (HTTP) -- using FMS)