Live DVR Rolling Window for HTTP dynamic streams
From osmf.adobe
Important! This feature requires OSMF 1.6, Flash Media Server 4.5, and a 2.0 format Flash Media Manifest (F4M) file.
About DVR rolling window
Because offering unlimited access to many hours of cached live content is rarely practical, content providers need to able to set a maximum duration for the viewing “window” that is available. However, because the event may continue for longer than the maximum window duration, the available content window can be said to “roll” forward with the current live point.
Example: A live event begins at 09:00, with a maximum window duration of 1 hour. At 09:05, at the beginning of the event, there is very little cached content to view, so the actual amount of viewable content is only 5 minutes. At 10:00, the cached content has reached its maximum size of 1 hour, so a user at that time could access a window of content extending from 09:00 to 10:00. However, as further time elapses and the event continues, the available content window “rolls” forward, such that someone viewing the event at 10:30 only has access to a window of content from 09:30 to 10:30. The previously available content beginning at 09:00 is no longer accessible to viewers.
Setting a DVR rolling window in Flash Media Server
With Flash Media Server 4.5, content providers can use the disk management feature together with a version 2.0 Flash Media Manifest file to specify a DVR rolling window.
By default with Flash Media Server 4.5, disk management is on and stores 3 hours of a live stream (this value can be adjusted in fractional units of an hour). The following Event.xml file stores 1.5 hours (90 minutes) of content, as specified by the DiskManagementDuration value:
<Event> <EventID>liveevent</EventID> <Recording> <FragmentDuration>4000</FragmentDuration> <SegmentDuration>60000</SegmentDuration> <DiskManagementDuration>1.5</DiskManagementDuration> </Recording> </Event>
To provide access to a specified amount of this content cache, the content provider can set the windowDuration attribute for the dvrInfo tag in an F4M 2.0 Manifest.xml file. (The dvrInfo tag in the Flash Media Manifest 1.0 file format contains the beginOffset and endOffset attributes, which could be used to create a type of open-ended rolling window. These attributes are deprecated with F4M 2.0.)
Set windowDuration as follows:
- To a value greater than zero, to indicate the number of seconds of recorded content that are available behind the live point. With HTTP streaming, the stream is typically a number of seconds behind the live point in most cases, so this value should be set to a reasonable amount that is not itself too close to 0, in order for DVR to function in a predictable fashion. A value of 60 seconds is recommended as the minimum
windowDuration. - To a value of negative one (-1), to indicate that the available recorded content behind the live point is unlimited. This is the default setting.
- Setting
windowDurationto zero is not recommended. To indicate a stream is “pure” live, with no DVR capability, thedvrInfotag simply should be omitted. It is not recommended to include thedvrInfotag and setwindowDurationto zero, as that can cause significant user experience issues. - To accommodate seeking and pausing at the beginning of the rolling window, the maximum
windowDurationshould be (DiskManagementDuration – segmentDuration). While it is possible to setwindowDurationto be equal toDiskManagementDuration, this is not recommended.
The following Manifest.xml file sets a rolling window of 60 minutes (3600 seconds):
<dvrInfo windowDuration="3600"> </dvrInfo>
Note: To set a DVR rolling window, use the Flash Media Server Set-level File Generator. This tool is installed to the <flashmediaserver>/tools/f4mconfig folder. You must use f4mconfig.html to create the file to load the individual F4M created by Flash Media Server. Alternately, you can (1) copy a file obtained as a Flash Media Server response, (2) set the baseURL for the file to the position of the first F4M file, and (3) edit the namespace manually: <manifest xmlns="http://ns.adobe.com/f4m/2.0">
Working with a DVR rolling window in OSMF
To support DVR rolling windows, you are not required to make changes to an existing OSMF player that supports classic DVR. OSMF manages the rolling window (including its current duration and the live point) automatically. If the stream is recording, OSMF always starts playback from the live point, regardless of the use of dvrInfo and windowDuration. This behavior is called “snap to live”.
Note: The “snap to live” behavior is new with OSMF 1.6. In OSMF 1.5, playback for HTTP streaming assets started from the beginning of the DVR content.
You can obtain the specified size of a rolling window from the windowDuration property of the DVRTrait for the media element associated with the content. However, because DVRTrait.windowDuration does not provide the actual amount of available content, the true amount of recorded content could be less than this value, if the event has been happening for less than a windowDuration amount of time.
To determine the actual amount of available content, as well as the current position of the playhead, you must examine properties of the media element’s TimeTrait, as follows:
-
TimeTrait.duration– the size of the cached content reported by OSMF, that is, the total duration of the available cached content -
TimeTrait.currentTime– the current position of the playhead, relative to the beginning of the rolling window; this value never exceedsTimeTrait.duration
You can use these values, along with the windowDuration property, if you want to customize your UI. For example, you might want to determine how long the player’s scrub bar should be or whether to use times relative to the beginning of the content or relative to the live point. An example of the latter would be to calculate TimeTrait.currentTime – TimeTrait.duration and have your player display times prior to the live point as negative numbers, reflecting the number of seconds the playhead is behind the live event. However, there is no requirement for you to do any of this, or to use DVRTrait.windowDuration property at all, in order to have a working player.
The following table provides an example of OSMF’s behavior when playing content with a DVR rolling window. In this example, a user starts viewing the stream 30 minutes after the event begins and immediately seeks backward 15 minutes to catch up with some of the content they have missed; windowDuration has been set by the content provider to be 60 minutes.
| Time from start of recording | TimeTrait.duration | TimeTrait.currentTime | Comments |
|---|---|---|---|
| 30 | 30 | 15 | This example is for a viewing session that begins 30 minutes after the start of event recording and which is immediately “rewound” 15 minutes back from the live point. |
| 45 | 45 | 30 | After 15 more minutes have passed, the real elapsed time for the event is still smaller than that set as a maximum size for the rolling window. |
| 60 | 60 | 45 | The event’s recorded content has now reached the size limit for the rolling window, as set by windowDuration. |
| 75 | 60 | 45 | The event recording has now exceeded windowDuration, so OSMF trims the available content to equal windowDuration, in this case 60 minutes. The current playhead time remains at 45 minutes; that is, the user is still viewing playback 15 minutes behind the live point, within a rolling window that is sized at 60 minutes. |
| 90 | 60 | 45 | The event concludes at minute 90, but the user is still 15 minutes behind the live point of the rolling window. The size of cached content is still 60 minutes. |
| 105 | 60 | 60 | 15 minutes after the event conclusion, the user has now caught up to the end of the available 60-minute cache. |
While there are no required player changes to make use of DVR rolling window, it is recommended that you implement a simple safety mechanism for your player, to ensure that the user doesn’t “fall out” of the rolling window. While the Strobe Media Playback project does not officially support DVR rolling window, it does provide an example of this safety mechanism at player/StrobeMediaPlayback/src/StrobeMediaPlayback.as . The player listens to the TimeEvent.CURRENT_TIME_CHANGE for the MediaPlayer, and, if the time becomes closer to the margin of the window than that specified by a preset value, the player seeks a set amount forward.
[...]
public function initialize(parameters:Object, stage:Stage, loaderInfo:LoaderInfo, pluginHostWhitelist:Array):void
{
[...]
player.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onCurrentTimeChange);
[...]
}
[...]
private function onCurrentTimeChange(event:TimeEvent):void
{
if ( player.state == MediaPlayerState.BUFFERING
|| player.state == MediaPlayerState.PLAYING
|| player.state == MediaPlayerState.PAUSED
) // If the player is in a relevant state
{
var dvrTrait:DVRTrait = player.media.getTrait(MediaTraitType.DVR) as DVRTrait;
if ((dvrTrait != null) && (dvrTrait.windowDuration != -1)) // If rolling window is present
{
if (event.time < DEFAULT_FRAGMENT_SIZE) // If we're too close to the left-most side of the rolling window
{
// Seek to a safe area
player.seek(DEFAULT_SEGMENT_SIZE);
}
}
}
}
[...]
private static const DEFAULT_FRAGMENT_SIZE:Number = 4;
private static const DEFAULT_SEGMENT_SIZE:Number = 16;
[...]
See also:
