http://blog.csdn.net/wutong_login/article/details/7819635
Streaming media over HTTP
Delivering content over HTTP is usually called “progressive download”. The content must transfer from the server to the client in a progression from the beginning to the end of a file. A client cannot seek to a forward location until that location and all the data before it has downloaded.
Delivering content over RTMP is called “streaming”. The client creates a socket connection to the server (such as Flash Media Server) over which the content is sent in a continuous stream. The client can seek to any point in the content instantly, regardless of how much data has been transferred.
Adobe HTTP Dynamic Streaming combines these approaches to introduce HTTP streaming to the Flash Platform. HTTP Dynamic Streaming packages media files into fragments that Flash Player clients can access instantly without downloading the entire file. Adobe HTTP Dynamic Streaming contains several components that work together to package media and stream it over HTTP to Flash Player and AIR. HTTP Dynamic Streaming supports multi-bitrate streaming, DVR, and Adobe�0�3 Flash�0�3 Access�6�4 protection.
In Flash Media Server 4.5, Adobe HTTP Dynamic Streaming adds support for Apple HTTP Live Streaming. Use the same HTTP Dynamic Streaming workflow to package and stream live and on-demand content to all devices that support Apple HTTP Live Streaming. Apple HTTP Live Streaming includes live and on-demand media.
HTTP Dynamic Streaming components
The Adobe HTTP Streaming solution contains the following components:
Live Packager Live Packager is a Flash Media Server application installed to rootinstall/applications/livepkgr. The server ingests a live stream over RTMP and the Live Packager translates it into F4F files and MPEG-2 TS files in real-time.
F4F HTTP Module An Apache HTTP Server module that serves files to Flash Player and AIR. The F4F module (also known as the HTTP Origin Module), serves live content. It also serves on-demand content that was packaged offline with the File Packager tool.
The F4F HTTP Module installs with Flash Media Server 4 and later torootinstall/Apache2.2/modules/mod_f4fhttp.so. The module is also available from adobe.com as a stand-alone Apache module.
HLS HTTP Module An Apache HTTP Server module that serves files to iOS devices and Mac OS.
The HTTP HLS Module installs with Flash Media Server 4.5 and later torootinstall/Apache2.2/modules/mod_hlshttp.so. It is not available as a stand-alone Apache module.
JIT HTTP Module An Apache HTTP Server module that packages on-demand files just-in-time and serves them to Flash Player and AIR. “Just-in-time” means that media files are packaged in real-time when clients request them.
The JIT HTTP Module installs with Flash Media Server 4.5 and later to rootinstall/Apache2.2/modules/mod_jithttp.so. It is not available as a stand-alone Apache module.
File Packager A command-line, offline tool that translates on-demand media into F4F fragments. The File Packager is located in the rootinstall/tools/f4fpackager folder and is available from adobe.com.
OSMF media players There are several media players built on the Open Source Media Framework (OSMF) that support HTTP Dynamic Streaming to Flash Player and AIR. See Pre-built media players.
F4F File Format Specification The F4F file format describes how to divide media content into segments and fragments. The Live Packager, the File Packager, and the JIT HTTP module output content based on this specification. Each fragment has its own bootstrap information that provides cache management and fast seeking. For more information, seeF4F File Format Specification.
F4M File Format Specification The Flash Media Manifest file format contains information about a package of files that the HTTP Origin Module can serve. Manifest information includes codecs, resolutions, and the availability of files encoded at multiple bit rates. Manifest information also includes DRM data. The media player uses the F4M file to play a piece of media. For more information, see F4M File Format Specification.
Flash Access Flash Access delivers protected media to Flash Player. To use HTTP Dynamic Streaming with Flash Access, use the File Packager and Flash Media Server to both package and encrypt content. For more information, see Protecting content with Flash Access.
Flash Media Server 4.5 adds support for Flash Access level protection without using a Flash Access server. See Configure protected HTTP Dynamic Streaming (PHDS) and Configure protected HTTP Live Streaming (PHLS).
Workflow for streaming live media over HTTP
The best way to experience the workflow for live HTTP streaming is to complete a tutorial. See Stream live media (HTTP).
The following is the workflow for all Adobe HTTP Dynamic Streaming and Apple HTTP Live Streaming use cases:
-
Use the default live event or create a live event.
The default live event is rootinstall/applications/livepkgr/events/_definst_/liveevent. Each live event contains configuration settings for one set of content. For more information, see Create and configure live events.
-
(Optional) To configure multi-bitrate streaming, use the Set-level F4M/M3U8 File Generator tool to generate an set-level manifest file. The set-level manifest file contains information about each stream. See Publish and play live multi-bitrate streams over HTTP.
-
(Optional) To configure DVR for Adobe HTTP Dynamic Streaming, create a set-level manifest file.
To configure a Sliding Window for Apple HTTP Live Streaming, configure the httpd.conf, Application.xml, or Event.xml file.
See Configure DVR (HDS) and Configure a sliding window (HLS).
-
(Optional—Adobe HTTP Dynamic Streaming) To encrypt content for protected HDS, see Configure protected HTTP Dynamic Streaming (PHDS).
To encrypt content for use with Flash Access, edit the Event.xml file. See Encrypt content for Flash Access protection.
-
(Optional—Apple HTTP Live Streaming) To encrypt content for Apple HTTP Live Streaming, see Protect content for Apple HLS.
-
Create a crossdomain.xml file and copy it to the rootinstall\webroot folder.
A crossdomain.xml file allows Flash Player clients hosted on other domains to access data from this domain. For more information, see Website controls (policy files) in the ActionScript 3.0 Developer’s Guide.
-
Publish a stream to the server.
-
(Adobe HTTP Dynamic Streaming) Use Strobe Media Playback to play media. Strobe Media Playback is installed with Flash Media Server.
-
(Apple HTTP Live Streaming) Play the content on iOS or MacOS.
For supported devices, see Apple HTTP Live Streaming documentation.
Workflow for streaming on-demand media over HTTP
The best way to experience the workflow for on-demand HTTP streaming is to complete a tutorial. See Stream on-demand media (HTTP).
The following is the workflow for Adobe HTTP Dynamic Streaming and Apple HTTP Live Streaming use cases:
-
Encode media files and copy them to the rootinstall/webroot/vod directory on Flash Media Server.
To configure this location, see Configure the location of content (HDS and HLS).
-
(Optional) To configure multi-bitrate streaming, use the Set-level F4M/M3U8 File Generator tool to generate a set-level manifest file. See Play on-demand multi-bitrate media files over HTTP.
-
(Optional—Adobe HTTP Dynamic Streaming) To encrypt content for protected HDS (without Flash Access), see Configure protected HTTP Dynamic Streaming (PHDS).
To encrypt content for use with Flash Access, edit the jit.conf file. See Encrypt content for Flash Access protection.
-
(Optional—Apple HTTP Live Streaming) To encrypt content for Apple HTTP Live Streaming, configure the jit.conf file or the Apache httpd.conf file. See Protect content for Apple HLS.
-
Create a crossdomain.xml file and copy it to the rootinstall\webroot folder.
A crossdomain.xml file allows Flash Player clients hosted on other domains to access data from this domain. For more information, see Website controls (policy files) in the ActionScript 3.0 Developer’s Guide.
-
(Adobe HTTP Dynamic Streaming) Use Strobe Media Playback to play media. Strobe Media Playback is installed with Flash Media Server.
-
(Apple HTTP Live Streaming) Play the content on an iOS device or on MacOS.
For supported devices, see Apple HTTP Live Streaming documentation.
Differences in HTTP Dynamic Streaming between Flash Media Server 4.0 and 4.5
The following are differences in HTTP Dynamic Streaming (HDS) between Flash Media Server 4.0 and 4.5:
-
Simplified request URLs for live streaming.
See Differences in HTTP live URLs from Flash Media Server 4.0 to Flash Media Server 4.5.
-
Support for just-in-time on-demand packaging.
When a media player requests an on-demand media files from the rootinstall/webroot/vod folder using HDS, Apache packages the stream in real-time. You do not need to pre-package the media files for HTTP streaming as you did with Flash Media Server 4.0. See Stream on-demand media (HTTP).
-
Use a jit.conf file to configure on-demand streaming at the stream-level. Copy the jit.conf file to the same folder as the media. See Configure on-demand HTTP streaming.
-
Use set-level F4M and M3U8 files to configure a set of streams for adaptive bitrate streaming.
The set-level files describe the bitrates of the media. The live and just-in-time packagers generate stream-level F4M and M3U8 files to describe the individual pieces of media. The set-level files can live on any webserver. See Publish and play live multi-bitrate streams over HTTP and Play on-demand multi-bitrate media files over HTTP.
Create and configure live events
You can use the livepkgr application to serve an unlimited number of live streaming events over HTTP (for example, a debate, a sporting event, and a town hall meeting). Each live streaming event requires its own configuration settings for multi-bitrate streaming, DVR, and content protection.
A live event is a configuration level within the livepkgr application. Like a Flash Media Server application, a live event is a folder on the server. The folder contains two configuration files: Manifest.xml and Event.xml. Use these configuration files to configure a set of streams.
Also like a Flash Media Server application, the name of the live event folder is the name of the live event. The Flash Media Server application that packages live content for HTTP streaming is called “livepkgr”. The livepkgr application contains a live event called “liveevent”:
rootinstall/applications/livepkgr/events/_definst_/liveevent
Streams in a live event are packaged as fragments and written to disk. A live event (the stream content and the metadata) exists until you delete it. A media player can access the content after the source stream has stopped publishing.
Create a live event
For each live streaming event, create a live event folder.
-
Create the following “events” folder structure in the livepkgr application folder:
rootinstall/applications/livepkgr/events/applicationinstancename/liveeventname
The following is a new live event called “liveevent2”:
rootinstall/applications/livepkgr/events/_definst_/liveevent2
You can also create a live event for a different instance of the livepkgr application, as in the following:
rootinstall/applications/livepkgr/events/anotherappinstance/liveevent
-
Copy the Events.xml file from the default liveevent folder to the new folder:
rootinstall/applications/livepkgr/events/_definst_/liveevent2/Events.xml
-
Copy the Manifest.xml file from the default liveevent folder to the new folder:
rootinstall/applications/livepkgr/events/_definst_/liveevent2/Manifest.xml
-
Open the Events.xml file in a text editor and change the event name:
<Event> <EventID>liveevent2</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>400000</SegmentDuration> <DiskManagementDuration>3</DiskManagementDuration> <Recording> </Event>
Configure a live event
For information about the features you can configure in the Event.xml file, see Configure live HTTP streaming at the event level (Event.xml).
Write server-side code to assign a stream to a live event
The Live Packager processes streams that are prefixed with f4f:. Flash Media Live Encoder doesn’t support the f4f: prefix so you must add it to the stream name in a server-side script or in a Flash Media Server Authorization Plug-in.
An application can contain more than one live event. For that reason, a stream published to an application is not associated with a live event by default. Use a server-side script or the Flash Media Server Authorization Plug-in (not both) to associate a live stream with a live event. You can associate a live stream with only one live event.
Associate a stream during the publish event. When the stream is published and associated, the server creates a stream record file (.stream) for the stream in the event directory:
applications/appname/events/appinstancename/liveeventname/livestream.stream
The stream record file contains information about the location of the packaged stream files. The HTTP Origin Module uses this information to generate an .f4m manifest file. For more information, see Understanding the application flow for live HTTP Dynamic Streaming.
Use Server-Side ActionScript
To see an example of this code, open rootinstall/applications/livepkgr/main.asc in a text editor.
-
Use the Stream.liveEvent property to associate a live stream with a live event before the server starts recording.
-
Add the f4f: prefix to the stream name. This tells the server to package the stream.
-
Call Stream.record() to record the stream.
Use an Authorization Plug-in
To perform these tasks with an Authorization plug-in, you must write the plug-in code.
-
Set the F_STREAM_TYPE field to "f4f".
-
Set the F_STREAM_LIVE_EVENT field to "liveeventname". This example uses “liveevent”.
-
Set the F_STREAM_PUBLISH_TYPE field to 0 which means "record".
The following is sample C++ code that handles the E_PUBLISH event:
case IFmsAuthEvent::E_PUBLISH: { // The name of the FMS app to which the live stream is published. char* pLiveApp = "livepkgr"; // The stream type used for HTTP Dynamic Streaming. char* pStreamType = "f4f"; // The name of the live event defined in the livepkgr app. char* pLiveEvent = "liveevent"; // The Auth Plug-in affects all apps on the server. // We only want to process streams published to the livehttp app. char* pAppName = getStringField(m_pAev, IFmsAuthEvent::F_APP_NAME); if (pAppName && !strncmp(pAppName, pLiveApp, strlen(pLiveApp))) { // Set the stream type. setStringField(m_pAev, IFmsAuthEvent::F_STREAM_TYPE, pStreamType); // Set the publish type to record. //0 record, 1 append, -1 live setI32Field(m_pAev, IFmsAuthEvent::F_STREAM_PUBLISH_TYPE, 0); // Associate the stream with a live event. setStringField(m_pAev, IFmsAuthEvent::F_STREAM_LIVE_EVENT, pLiveEvent); } }
Content storage (HDS and HLS)
Configure the beginning of the request URL
When a media player requests content from the server, it passes the server a request URL. The section of the request URL following the server name (and optional port number) is defined in the Location directive path in the Apache httpd.conf file. For example, the following is the Location directive for HDS on-demand streaming:
<IfModule jithttp_module>
<Location /hds-vod>
HttpStreamingJITPEnabled true
HttpStreamingContentPath "../webroot/vod"
JitFmsDirPath ".."
Options -Indexes FollowSymLinks
</Location>
</IfModule>
When Apache receives a request with the path /hds-vod, it uses the jithttp_module (just-in-time) to process the request. The jithttp_module uses the values of the directives nested within the Location directive.
To configure HTTP streaming for multiple tenants, or for multiple applications, add Location directives with different paths. The following table lists the syntax for request URLs, theLocation directive paths are in bold:
Streaming type |
Request URL syntax |
---|---|
Adobe HDS live |
http://<fms-dns-or-ip>/hds-live/livepkgr/<appinstname>/<eventname>/<streamname>.f4m |
Apple HLS live |
http://<fms-dns-or-ip>/hls-live/livepkgr/<appinstname>/<eventname>/<streamname>.m3u8 |
Adobe HDS on-demand with just-in-time packaging |
http://<fms-dns-or-ip>/hds-vod/<streamname>.<fileextension>.f4m |
Apple HLS on-demand |
http://<fms-dns-or-ip>/hls-vod/<streamname>.<fileextension>.m3u8 |
-
Open rootinstall/Apache2.2/conf/httpd.conf in a text editor.
-
Location the Location directive for the streaming type you want to edit, copy it, and paste it.
-
For example, to create a Location for HDS on-demand streaming, copy the /hds-vod section and paste it underneath the existing section.
<IfModule jithttp_module> <Location /hds-vod> HttpStreamingJITPEnabled true HttpStreamingContentPath "../webroot/vod" JitFmsDirPath ".." Options -Indexes FollowSymLinks # Uncomment the following directives to enable encryption # for this location. # EncryptionScope server # ProtectionScheme phds </Location> </IfModule>
-
In the copied section, change the Location path to /flash-vod. You can also edit the HttpStreamingContentPath directive to change the location of the on-demand media on disk.
<IfModule jithttp_module> <Location /flash-vod> HttpStreamingJITPEnabled true HttpStreamingContentPath "../webroot/vod2" JitFmsDirPath ".." Options -Indexes FollowSymLinks # Uncomment the following directives to enable encryption # for this location. # EncryptionScope server # ProtectionScheme phds </Location> </IfModule>
Note: To change the location of content for live streaming, see Configure the location of live HDS and HLS content. -
Create the rootinstall/webroot/vod2 folder and copy the sample1_1500kbps.f4v file to it from the /webroot/vod folder.
-
Restart Apache HTTP Server. The service name is FMSHttpd.
-
Double-click rootinstall/samples/videoPlayer/videoplayer.html to open the Flash Media Server sample video player.
-
Enter the following in the Stream URL text box:
http://localhost/flash-vod/sample1_1500kbps.f4v.f4m
You can play any file from the /webroot/vod2 folder.
Configure the location of on-demand HDS and HLS content
To configure the location of on-demand content on disk, edit the Apache httpd.conf file. Use the following directives:
Directive |
Description |
---|---|
HttpStreamingContentPath |
The root location of the streams. This value can be absolute or relative to the Apache root folder. By default, the location for on-demand HDS and HLS is "../webroot/vod". |
-
Open rootinstall/Apache2.2/conf/httpd.conf
-
To change the location on the server where media is stored for on-demand streaming, edit the HttpStreamingContentPath directive. For example, the following changes the location to c:\hds_vod_content:
<IfModule jithttp_module> <Location /hds-vod> HttpStreamingJITPEnabled true # HttpStreamingContentPath "../webroot/vod" HttpStreamingContentPath "C:\hds_vod_content" JitFmsDirPath ".." Options -Indexes FollowSymLinks # Uncomment the following directives to enable encryption # for this location. # EncryptionScope server # ProtectionScheme phds </Location> </IfModule> <Location /hls-vod> HLSHttpStreamingEnabled true HLSMediaFileDuration 8000 # HttpStreamingContentPath "../webroot/vod" HttpStreamingContentPath "C:\hds_vod_content" HLSFmsDirPath ".." # Uncomment the following directives to enable encryption # for this location. # HLSEncryptionScope server # HLSEncryptCipherKeyFile "../phls/vodkey.bin" # HLSEncryptKeyURI "https://<ServerName>/hls-key/vodkey.bin" Options -Indexes FollowSymLinks</Location>
-
Restart the Apache HTTP Server. The service name is FMSHttpd.
-
Copy a sample file from /webroot/vod to c:\hds_vod_content. This task uses sample1_1500kbps.f4v.
-
(HDS) Open rootinstall/samples/videoPlayer/videoplayer.html in a browser and in the Stream URL text box, enter:
http://localhost/hds-vod/sample1_1500kbps.f4v.f4m
-
(HLS) On a device running iOS, open Safari and enter the following:
http://localhost/hls-vod/sample1_1500kbps.f4v.m3u8
The request URL is the same as it was before the Apache configuration change, but the content is in a different location on the disk. When Apache receives a request that start with /hds-vod, it resolves the rest of the path based on the value of HttpStreamingContentPath.
To verify that the Apache configuration took effect, try to stream a sample file that isn’t in the c:\hds_vod_content folder. For example, try to stream http://localhost/hds-vod/sample1_1000kbps.f4v.f4m. The sample video player displays an error, “We are unable to connect to the content you’ve requested. We apologize for the inconvenience.”
Configure the location of live HDS and HLS content
To configure the location of live HDS and HLS content on disk, edit the Apache httpd.conf file. Use the following directives:
Directive |
Description |
---|---|
HttpStreamingContentPath |
The root location of the streams on disk (livepkgr/streams, by default). By default, the location is "../applications". This location must be a subfolder of the livepkgr application. This value can be absolute or relative to the Apache root folder. |
HttpStreamingLiveEventPath |
The root location of live events on disk (livepkgr/events, by default). The default value is "../applications". This location must be a subfolder of the livepkgr application. This value can be absolute or relative to the Apache root folder. For HLS, this value is dependant on the value of the HttpStreamingURLSandboxLevel directive. |
HttpStreamingURLSandboxLevel |
Defines the scope at which HttpStreamingLiveEventPath is configured. Possible values are "App", "Inst", and "Server". The default value is"Server". If HttpStreamingLiveEventPath is configured to a particular application, use the value "App". In this case, the client request URL can omit the application name, as in the following: HttpStreamingLiveEventPath "..application/livepkgr" HttpStreamingURLSandboxLevel "App" The request URL is:
http://<fms-dns-or-ip>/hls-live/<app-instance>/<event-name>/<stream-name>.m3u8 If HttpStreamingLiveEventPath is configured to an application instance, use the value "Inst". In this case, the client request URL can omit the application name and the application instance, as in the following: HttpStreamingLiveEventPath "..application/livepkgr/events/_definst_" HttpStreamingURLSandboxLevel "Inst" The request URL is:
http://<fms-dns-or-ip>/hls-live/<event-name>/<stream-name>.m3u8 |
Configure the location of the live content on disk
-
Open rootinstall/conf/fms.ini in a text editor. Set the VHOST.APPSDIR in parameter to one of the following:
-
(Windows) C:/applications
-
(Linux) /opt/applications
-
-
Restart the server.
-
Create a folder at the location in step 1 and copy the livepkgr application to it.
-
Open rootinstall/Apache2.2/conf/httpd.conf in a text editor.
-
To change the location of the HDS live content, edit the directives in bold:
<Location /hds-live> HttpStreamingEnabled true # HttpStreamingLiveEventPath "../applications" # HttpStreamingContentPath "../applications" HttpStreamingLiveEventPath "C:\applications"HttpStreamingContentPath "C:\applications" HttpStreamingF4MMaxAge 2 HttpStreamingBootstrapMaxAge 2 HttpStreamingFragMaxAge -1 HttpStreamingDrmmetaMaxAge 3600 Options -Indexes FollowSymLinks </Location> </IfModule>
Note: On Linux, use "/opt/applications". -
To change the location of HLS live content, edit the directives in bold:
<IfModule hlshttp_module> <Location /hls-live> HLSHttpStreamingEnabled true # HttpStreamingLiveEventPath "../applications" # HttpStreamingContentPath "../applications" HttpStreamingLiveEventPath "C:\applications"HttpStreamingContentPath "C:\applications" HLSMediaFileDuration 8000 HLSSlidingWindowLength 6 HLSFmsDirPath ".." HLSM3U8MaxAge 2 HLSTSSegmentMaxAge -1 # Uncomment the following directives to enable encryption # for this location. # HLSEncryptionScope server # HLSEncryptCipherKeyFile "../phls/liveeventkey.bin" # HLSEncryptKeyURI "https://<ServerName>/hls-key/liveeventkey.bin" Options -Indexes FollowSymLinks </Location>
-
Restart Apache HTTP Server. The service name is FMSHttpd.
-
Open Flash Media Live Encoder and publish a stream with the following settings:
-
Video codec—H.264
-
Audio codec—AAC
-
Keyframe Frequency—4 seconds
-
FMS URL—rtmp://localhost/livepkgr
-
Stream—livestream?adbe-live-event=liveevent
-
-
(HDS) Open rootinstall/samples/videoPlayer/videoplayer.html in a browser and in the Stream URL text box, enter:
http://localhost/hds-live/livepkgr/_definst_/liveevent/livestream.f4m
-
(HLS) On a device running iOS, open Safari and enter:
http://localhost/hls-live/livepkgr/_definst_/liveevent/livestream.m3u8
Note: To play content in Safari 4.0 on Mac OS, create an HTML document that uses the <video> tag.
Configure the scope of the request URL
-
Open rootinstall/Apache2.2/conf/httpd.conf in a text editor.
-
To change the scope of the request URL (also called the URL sandbox level) for HDS, edit the directives in bold:
<Location /hds-live> HttpStreamingEnabled true # HttpStreamingLiveEventPath "../applications" # HttpStreamingContentPath "../applications" HttpStreamingLiveEventPath "c:\applications\livepkgr" HttpStreamingContentPath "c:\applications" HttpStreamingURLSandboxLevel "App" HttpStreamingF4MMaxAge 2 HttpStreamingBootstrapMaxAge 2 HttpStreamingFragMaxAge -1 Options -Indexes FollowSymLinks </Location></IfModule>
To change the scope of the request URL for HLS, edit the directives in bold:
<IfModule hlshttp_module> <Location /hls-live> HLSHttpStreamingEnabled true # HttpStreamingLiveEventPath "../applications" # HttpStreamingContentPath "../applications" HttpStreamingLiveEventPath "C:\applications\livepkgr" HttpStreamingContentPath "C:\applications" HttpStreamingURLSandboxLevel "App" HLSMediaFileDuration 8000 HLSSlidingWindowLength 6 HLSFmsDirPath ".." HLSM3U8MaxAge 2 HLSTSSegmentMaxAge -1 # Uncomment the following directives to enable encryption # for this location. # HLSEncryptionScope server # HLSEncryptCipherKeyFile "../phls/liveeventkey.bin" # HLSEncryptKeyURI "https://<ServerName>/hls-key/liveeventkey.bin" Options -Indexes FollowSymLinks </Location>
-
Restart the Apache HTTP Server. The service name is FMSHttpd.
-
Open Flash Media Live Encoder and publish a stream with the following settings:
-
Video codec—H.264
-
Audio codec—AAC
-
Keyframe Frequency—4 seconds
-
FMS URL—rtmp://localhost/livepkgr
-
Stream—livestream?adbe-live-event=liveevent
-
-
(HDS) Double-click rootinstall/samples/videoPlayer/videoplayer.html to open the Flash Media Server sample video player. Enter the following for Stream URL and click play:
http://<host>/hds-live/_definst_/liveevent/livestream.f4m
-
On a device running iOS, open Safari and enter:
http://<host>/hls-live/_definst_/liveevent/livestream.m3u8
Because the URL sandbox level is configured to “App” instead of the default “Server”, the URL does not include the application name (livepkgr).
Configure set-level F4M/M3U8 files for multi-bitrate streaming
Configuration information about multi-bitrate streams has been divided into multiple levels: set-level F4M and M3U8 files and stream-level F4M and M3U8 files. For HDS, the files are F4M manifest files. For HLS, the files are M3U8 variant playlists. (The documentation sometimes uses the generic term “manifest” to refer to both.)
Flash Media Server 4.5 includes a Set-level F4M/M3U8 File Generator tool. This tool is installed to rootinstall/tools/f4mconfig/configurator/f4mconfig.html. Use the tool to generate set-level files. Copy the set-level files to a web server. The media player requests set-level files to play multi-bitrate content.
The following is a set-level F4M file:
<manifest xmlns="http://ns.adobe.com/f4m/2.0"> <baseURL>http://localhost/hds-live/livepkgr/_definst_/liveevent/</baseURL> <media href="livestream1.f4m" bitrate="150"/> <media href="livestream2.f4m" bitrate="500"/> <media href="livestream3.f4m" bitrate="700"/> </manifest>
The following is a set-level M3U8 file:
#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=150000 http://10.0.1.11/hls-live/livepkgr/_definst_/liveevent/livestream1.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=500000 http://10.0.1.11/hls-live/livepkgr/_definst_/liveevent/livestream2.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=700000 http://10.0.1.11/hls-live/livepkgr/_definst_/liveevent/livestream3.m3u8
Stream-level F4M and M3U8 files contain bootstrap information and DRM metadata. The live packager and the HTTP modules generate stream-level F4M and M3U8 files in real time when a media player requests the content.
Flash/AIR media players that support set-level files To play set-level F4M files, use a media player that uses OSMF 1.6 or later. Strobe Media Playback that installs torootinstall/samples/videoPlayer supports set-level F4M files.
Apple media players that support set-level files To play set-level M3U8 files, use any device that supports Apple HTTP Live Streaming. See the Apple HTTP Live Streaming documentation.
F4M specification For detailed information about the F4M file format, see the F4M File Format Specification.
M3U8 specification For detailed information about the M3U8 file format, see HTTP Live Streaming Internet-Draft.
Tutorials that use set-level files The following tutorials use set-level files for multi-bitrate streaming:
Configure absolute time on the server
The livepkgr ingest application is configured by default to use absolute time. To see the configuration, open rootinstall/applications/livepkgr/Application.xml in a text editor.
To publish live, multi-bitrate streams, configure the live encoder to publish the streams using absolute time. See Stream live media (HTTP).
-
Copy an Application.xml file to the application folder.
For example, if you’re publishing streams to the application “livepkgr2”, copy an Application.xml file from the conf\_defaultRoot_\_defaultVHost_ folder to the applications/livepkgr2 folder.
-
Open the Application.xml file in a text editor.
-
Set the tag //Application/StreamManager/Live/AssumeAbsoluteTime to true:
<Application> ... <StreamManager> ... <Live> ... <AssumeAbsoluteTime>true</AssumeAbsoluteTime>
-
Save the file.
-
Restart the server. See Starting and stopping the server.
Configure F4F and TS fragment duration
The server records ingested (live) streams into fragments. It records on-demand files into fragments when a client requests the files.
Adobe HDS fragments are F4F files. Apple HLS fragments are TS files.
Specify the size of content fragments based on frames or based on time. The frame-based configuration overrides the time-based configuration.
Use frame-based configuration when the source media contains video encoded at a constant frame rate. Use frame-based configuration to match the fragment size to the video's keyframe interval. Use time-based configuration for media that contains audio or data but not video.
The server’s fragment duration must be a multiple of the encoder’s keyframe interval. The value of KeyframeIntervalsPerFragment defines the multiple.
Configure fragment size for live HDS and HLS
Server-level configurations for live HDS
Set the following directive in the Apache httpd.conf to configure fragment size for all live HDS events on the server:
Directive |
Description |
Default |
---|---|---|
HttpStreamingFragmentDuration |
The default fragment duration, in milliseconds. This is the time-based configuration, and can be overridden by selecting frame-based values. |
4000 |
HttpStreamingFrameRate |
For frame-based fragment duration configuration, this is the frame rate of the source content. |
None |
HttpStreamingFramesPerKeyframeInterval |
For frame-based fragment duration configuration, this is the number of frames in each keyframe interval (group of pictures). |
None |
HttpStreamingKeyframeIntervalsPerFragment |
For frame-based fragment duration configuration, this is the number of keyframe intervals (GOPs) per fragment. |
1 |
Server-level configurations for live HLS
Set the following directive in the Apache httpd.conf to configure a time-based fragment size for all live HLS events on the server:
Directive |
Description |
Default |
---|---|---|
HLSMediaFileDuration |
The duration of TS files, in milliseconds. Use a value that is a multiple of the keyframe intervals for the media. |
8000 |
Application-level and event-level configurations for live HDS
To configure fragment size at the application-level, use the Application.xml file in the directory of the Live Packager application (livepkgr, by default).
To configure fragment size at the event-level, use the Event.xml file in the live event directory (applications/livepkgr/events/_definst_/liveevent, by default).
Use the elements in the <Recording> container to configure how the server writes files to disk. In the Application.xml file, the elements are located at //Application/HDS. In the Event.xml file, the elements are located at //Event.
Application-level and event-level configurations for live HLS
To configure fragment size at the application-level, use the Application.xml file in the directory of the Live Packager application (livepkgr, by default).
To configure fragment size at the event-level, use the Event.xml file in the live event directory (applications/livepkgr/events/_definst_/liveevent, by default).
Use the elements in the <Recording> and <HLS> containers to configure how the server writes files to disk. In the Application.xml file, the elements are located at //Application/HDS. In the Event.xml file, the elements are located at //Event/.
Element |
Description |
Default |
---|---|---|
/Recording/FrameRate |
The frame rate of the original content, in frames per second (fps). The value is floating point; for NTSC, use the value 29.97. Frame-based configuration. |
None |
/Recording/FramesPerKeyframeInterval |
The number of frames between each keyframe. For example, 30 fps video with a keyframe every 2 seconds contains 60 frames per keyframe interval. Frame-based configuration. |
None |
/HLS/KeyframeIntervalPerMediaFile |
The number of keyframe intervals per media file (TS). The default value is 1, which means that the fragment size is the same as the keyframe interval. Frame-based configuration. |
1 |
/HLS/MediaFileDuration |
The length of each media file (TS), in milliseconds. Time-based configuration. Frame-based configurations override time-based configurations |
8000 |
Specify fragment size for live HDS and HLS based on frames
Use the following elements for HDS: KeyframeIntervalsPerFragment, FrameRate, FramesPerKeyframeInterval, FramePrecision.
Use the following elements for HLS: FrameRate, FramesPerKeyframeInterval, and KeyframeIntervalPerMediaFile.
<Event> <EventID>liveevent</EventID> <Recording> <FrameRate>29.97</FrameRate> <FramesPerKeyframeInterval>120</FramesPerKeyframeInterval> <KeyframeIntervalsPerFragment>1</KeyframeIntervalsPerFragment> <FramePrecision>1</FramePrecision> </Recording> <HLS> <KeyframeIntervalPerMediaFile>3</KeyframeIntervalPerMediaFile> </HLS> </Event>
The server calculates the HLS media file duration according to the following formula:
MediaFileDurationInSeconds = FramesPerKeyframeInterval * KeyframeIntervalPerMediaFile / FrameRate
Specify fragment size for live HDS and HLS based on time
Use the following elements for HDS: FragmentDuration, SegmentDuration.
Use the following element for HLS: MediaFileDuration.
Use the following elements: FragmentDuration, MediaFileDuration.
<Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>400000</SegmentDuration> </Recording> <HLS> <MediaFileDuration>8000<MediaFileDuration> </HLS> </Event>
Configure fragment size for on-demand HDS and HLS
Server-level configurations for on-demand HDS
Set the following directive in the Apache httpd.conf to configure fragment size for all on-demand HDS on the server:
Directive |
Description |
Default |
---|---|---|
HttpStreamingFragmentDuration |
The default fragment duration, in milliseconds. This is the time-based configuration. Frame-based configurations override time-based configurations. |
4000 |
HttpStreamingFrameRate |
The frame rate of the source content. Frame-based configuration. |
None |
HttpStreamingFramesPerKeyframeInterval |
The number of frames in each keyframe interval (group of pictures. Frame-based configuration. |
None |
HttpStreamingKeyframeIntervalsPerFragment |
The number of keyframe intervals (GOPs) per fragment. Frame-based configuration. |
1 |
Server-level configurations for on-demand HLS
Set the following directive in the Apache httpd.conf to configure fragment size for all on-demand HLS on the server:
Directive |
Description |
Default |
---|---|---|
HLSMediaFileDuration |
The duration of TS files, in milliseconds. Use a value that is a multiple of the keyframe intervals for the media. |
8000 |
Stream-level configurations for on-demand HDS
To configure a set of on-demand media files (or a single file), copy a jit.conf file to the same directory as the media files. All media files in a directory use the same jit.conf file.
Use a jit.conf file with the following elements to configure fragment size for HDS at the stream-level:
Element |
Description |
Default |
---|---|---|
//manifest/hds:fragment-duration |
The fragment duration for the set of content, in seconds. The value can be fractional (for example, to specify 2002 milliseconds, use the value 2.002). Time-based configuration. Frame-based configurations override time-based configurations |
None |
//manifest/hds:frame-rate |
The frame rate of the set of content. Units are frames/second, and can be fractional (i.e. 29.97 for NTSC) . Frame-based configuration. |
None |
//manifest/hds:frames-per-keyframe-interval |
The number of frames per keyframe interval (GOP). Units are frames, and should be a whole integer value. Frame-based configuration. |
None |
//manifest/hds:keyframe-intervals-per-fragment |
The number of keyframe intervals per fragment. Units are keyframe intervals per fragment, and should be a whole integer value. Frame-based configuration. |
1 |
Stream-level configurations for on-demand HLS
To configure a set of on-demand media files (or a single file), copy a jit.conf file to the same directory as the media files. All media files in a directory use the same jit.conf file.
Use a jit.conf file with the following elements to configure fragment size for HLS at the stream-level:
Element |
Description |
Default |
---|---|---|
//manifest/hds:frame-rate |
The frame rate of the set of content. Units are frames/second, and can be fractional (i.e. 29.97 for NTSC) . Frame-based configuration. |
None |
//manifest/hds:frames-per-keyframe-interval |
The number of frames per keyframe interval (GOP). Units are frames, and should be a whole integer value. Frame-based configuration. |
None |
//manifest/hds:hls |
Container for Apple HTTP Live Streaming configurations. |
None |
//manifest/hds:hls/hds:keyframe-intervals-per-media-file |
The number of keyframe intervals per TS file duration. The value must be a whole integer. Frame-based configuration. |
None |
//manifest/hds:hls/hds:media-file-duration |
The TS file duration, in milliseconds, for the set of content associated with this file. Use a value that is a multiple of the fragment duration. Time-based configuration. Frame-based configurations override time-based configurations |
None |
Specify fragment size for on-demand HDS and HLS based on frames
Use the following elements for HDS: hds:frame-rate, hds:frames-per-keyframe-interval, and hds:keyframe-intervals-per-fragment.
Use the following elements for HLS: hds:frame-rate, hds:frames-per-keyframe-interval, and hds:keyframe-intervals-per-media-file.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns="http://ns.adobe.com/f4m/1.0" xmlns:hds="http://ns.adobe.com/hds-package/1.0"> <hds:frame-rate>29.97</hds:frame-rate> <hds:frames-per-keyframe-interval>60</hds:frames-per-keyframe-interval> <hds:keyframe-intervals-per-fragment>2</hds:keyframe-intervals-per-fragment> <hds:hls> <hds:keyframe-intervals-per-media-file>2</hds:keyframe-intervals-per-media-file> </hds:hls> </manifest>
Specify fragment size for on-demand HDS and HLS based on time
Use the following element for HDS: hds:fragment-duration.
Use the following element for HLS: hds:media-file-duration.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns="http://ns.adobe.com/f4m/1.0" xmlns:hds="http://ns.adobe.com/hds-package/1.0"> <hds:fragment-duration>8000</hds:fragment-duration> <hds:hls> <hds:media-file-duration>8000</hds:media-file-duration> </hds:hls> </manifest>
Configure the size of the IO buffer
The IO buffer improves the read and write performance of the Apache f4f module. The IO buffer loads the disk file into an in-memory buffer. It reads and writes to the in-memory buffer instead of making system calls.
When the buffer is full, or if the read/write head needs to move beyond the buffer boundaries, the server commits the contents of the buffer to the disk file and pre-loads new content into the buffer from the disk file.
The default value of the IO buffer is 4096 bytes. To increase or decrease the value, edit the Event.xml file. Use a multiple of 4096 bytes.
-
Open the Event.xml file in a text editor.
For live HTTP streaming, the Event.xml file is located in the live event folder. For example, rootinstall/applications/livepkgr/events/_definst_/liveevent/Event.xml.
-
Set the IOBufferSize to a value that is a multiple of the cluster size of the underlying operating system. IOBufferSize is the size of the IO buffer in bytes.
<Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <IOBufferSize>4096</IOBufferSize> </Recording> </Event>
-
Save the file.
Disk management
Set the DiskManagementDuration configuration parameter in the Application.xml file or the Event.xml file to specify how much of the latest live content is on disk. The limit set at the application level cannot be overriden at the event level. If the limit has been set in the Application.xml file, the Event.xml file can set a duration that is equal to or lower than that limit.
All live HTTP streaming uses disk management to prevent the disk from filling. Disk management allows you to create 24/7 live streaming events. In addition, when using DVR, configure disk management in relation to the DVR settings. See Configure DVR (HDS).
By default, disk management keeps 3 hours of a live stream. The server constantly checks the content and if the content duration is above the value of DiskManagmentDuration, the server deletes the .f4f files and the .f4x files for segments beyond the limit.
If SegmentDuration or DiskManagmentDuration have values (both do by default), the following formula must be true for the server to start recording:
FragmentDuration < SegmentDuration < DiskManagementDuration
Also, the value of SegmentDuration must be greater than 0. (The value 0 creates 1 segment.) The value of SegmentDuration specifies how rapidly segments are removed. The smaller the value of SegmentDuration, the faster segments are deleted.
The server maintains the total duration of all the content available. After a segment is created, the server checks if the segment does not have any fragments that are in the disk management window. If so, the server removes the segment from the bootstrap entries, then removes the segment from disk.
Element |
Default |
Description |
---|---|---|
DiskManagementDuration |
3 |
The maximum duration of the content on the server, in hours. The default value is 3. Use a fractional value to specify minutes. |
The value of DiskManagementDuration in the Application.xml file cannot be overridden by the value in the Event.xml file. If a value is not set in Application.xml, you can set a value in Event.xml.
The following sets disk management duration to 4 hours in the Application.xml file. This value impacts all live events running in this application.
<Application> ... <HDS> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>16000</SegmentDuration> <DiskManagementDuration>4</DiskManagementDuration> </Recording> </HDS> </Application>
The following sets the disk management duration to 1 hour in the Event.xml file. This value limits the content duration on the server for the event called “liveevent.”
<Event> <EventID>liveevent</EventID> <Recording> ... <DiskManagementDuration>1</DiskManagementDuration> </Recording> </Events>
For more information, see Configure live HTTP streaming.
Configure content caching (HDS)
To improve the performance of live and on-demand HTTP Dynamic Streaming, enable Apache content caching on the origin server. When caching is enabled, the server caches content that it packages for HDS. When the server receives a request, it checks the cache before it serves content. Content caching is disabled by default.
-
Run the htcacheclean tool.
To limit the amount of storage the disk cache uses, run the Apache htcacheclean tool when content caching is enabled. The tool can run manually or as a daemon. The htcacheclean tool is located at rootinstall/Apache2.2/bin/. For information about how to run the tool, see the Apache documentation.
-
In the Apache httpd.conf file, uncomment the caching configuration section.
# Uncomment this to enable caching LoadModule cache_module modules/mod_cache.so <IfModule mod_cache.c> LoadModule disk_cache_module modules/mod_disk_cache.so IfModule mod_disk_cache.c> CacheEnable disk /hds-vod CacheEnable disk /hls-vod CacheRoot cacheroot CacheMaxFileSize 10000000 CacheLock On </IfModule> </IfModule>
Verify that the directory specified by the CacheRoot directive exists. The default cacheroot directory is located at rootinstall/Apache2.2/cacheroot.
-
Restart Apache.
For more information about content caching, see the Apache documentation.
Encrypt content for Flash Access protection
After you’ve deployed Flash Access Server for Protected Streaming, configure Flash Media Server to package and encrypt the content in real-time.
Configure Flash Media Server to encrypt live content
You can configure live content encryption with Flash Access at the application level and at the event level.
To configure Flash Access at the application level, use the Application.xml file located here:
rootinstall/applications/livepkgr/Application.xml
In the Application.xml file, the FlashAccessV2 container element is located here:
//Application/HDS/Recording/ContentProtection/FlashAccessV2
To configure Flash Access at the event level, use the Event.xml file located here:
rootinstall/applications/livepkgr/events/_definst_/liveevent/Event.xml
In the Event.xml file, the FlashAccessV2 container element is located here:
//Event/Recording/ContentProtection/FlashAccessV2
-
Open the file rootinstall/applications/livepkgr/events/_definst_/liveevent/Event.xml in a text editor.
-
Add the XML tags required for encrypting the streams. The following is a sample Event.xml file:
<Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>10000</SegmentDuration> <ContentProtection enabled="true"> <ProtectionScheme>FlashAccessV2</ProtectionScheme> <FlashAccessV2> <ContentID>foo</ContentID> <CommonKeyFile>common-key.bin</CommonKeyFile> <LicenseServerURL>http://dill.corp.adobe.com:8090</LicenseServerURL> <TransportCertFile>production_transport.der</TransportCertFile> <LicenseServerCertFile>license_server.der</LicenseServerCertFile> <PackagerCredentialFile>production_packager.pfx</PackagerCredentialFile> <PackagerCredentialPassword>hbXX5omIhzI=</PackagerCredentialPassword> <PolicyFile>policy01.pol</PolicyFile> </FlashAccessV2> </ContentProtection> </Recording> </Event>
Note: The certificates that you use with the Live Packager must match the license server.
Element |
Description |
Default value |
---|---|---|
FlashAccessV2 |
A container for settings used by Flash Access to protect content. |
None |
FlashAccessV2/CommonKeyFile |
A path to a common key file used to generate a content encryption key. The path should be absolute or relative to the configuration file. The base key used with the content ID to generate the content encryption key. This is a binary file containing a 16-byte/128-bit binary key. For adaptive bitrate streaming, use the same common key and content ID for an entire set of content. Using the same key and id allows a single license to decrypt a set of content. |
None |
FlashAccessV2/ContentID |
The content ID used with the common key to generate the content encryption key. |
None |
FlashAccessV2/LicenseServerCertFile |
The DER encoded license server certificate file used for content protection. |
None |
FlashAccessV2/LicenseServerURL |
The URL of the license server that handles license acquisition for this content. |
None |
FlashAccessV2/PackagerCredentialFile |
The PFX file containing the packager's protection credentials. |
None |
FlashAccessV2/PackagerCredentialPassword |
The password string used to secure the packager credentials. |
None |
FlashAccessV2/PolicyFile |
The file containing the policy for this content. Currently only a single policy can be applied to content packaged with this tool. |
None |
FlashAccessV2/TransportCertFile |
The DER encoded transport certificate file. |
None |
The Live Packager outputs the fragmented and protected files needed for HTTP Dynamic Streaming. Each fragment is persistently protected in both the CDN cache and the browser cache.
Configure Flash Media Server to encrypt on-demand content:
-
Create a file called jit.conf and copy it to the same folder as the on-demand media files. The settings in the jit.conf file apply to all the files in the folder.
-
Add the XML tags required for encrypting the streams. The following is a sample jit.conf file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns="http://ns.adobe.com/f4m/1.0" xmlns:hds="http://ns.adobe.com/hds-package/1.0"> <hds:frame-rate>29.97</hds:frame-rate> <hds:frames-per-keyframe-interval>60</hds:frames-per-keyframe-interval> <hds:content-protection enabled="true"> <hds:protection-scheme>FlashAccessV2</hds:protection-scheme> <hds:FlashAccessV2> <hds:content-id>myfile.manifest</hds:content-id> <hds:common-key-file>common.bin</hds:common-key-file> <hds:license-server-url>http://mylicenseserver.myhost.com</hds:license-server-url> <hds:transport-cert-file>transport.der</hds:transport-cert-file> <hds:license-server-cert-file>server.der</hds:license-server-cert-file> <hds:packager-credential-file>packager.pfx</hds:packager-credential-file> <hds:packager-credential-password>??????</hds:packager-credential-password> <hds:policy-file>policy.pol</hds:policy-file> </hds:FlashAccessV2> </hds:content-protection> </manifest>
Element |
Description |
Default |
---|---|---|
//manifest/hds:content-protection/hds:flash-access/hds:common-key-file |
The path to common key file. File contains 16-byte/128-bit random key. The path must be absolute or relative to the jit.conf file. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:content-id |
The Content ID to be used for content protection. If not specified, the salt is the filename. If specified, the salt is shared with all content in the directory. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:license-server-url |
The License Server URL. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:transport-cert-file |
The path to transport cert file. The file is in DER format. The path should be absolute or relative to the jit.conf file. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:license-server-cert-file |
The path to transport cert file. File is in DER format. The path should be absolute or relative to the jit.conf file. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:packager-credential-file |
The path to packager credential cert file. File is in PFX format. The path should be absolute or relative to the jit.conf file. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:packager-credential-password |
The packager credential password. |
None |
//manifest/hds:content-protection/hds:flash-access/hds:policy-file |
The path to a policy file. File is in FAXS policy format. The path should be absolute or relative to the jit.conf file. |
None |
Publish live streams
Publish a live stream or multi-bitrate streams from a supported encoder to the livepkgr service. Flash Access doesn’t require any special settings.
Play encrypted streams
-
Request the file fragments and play them back seamlessly.
-
Obtain a content license from Flash Access Server for Protected Streaming. The content license contains the key required to play the content to legitimate clients.
-
Decrypt the content in real-time.