OCTOBER 25 2011

FMS 4.0 HDS Configuration Recommendations

Related Categories: Flash Media Server, Flash Platform Best Practices,

The following are my best practice recommendations for Live HTTP Dynamic Streaming (HDS) with Adobe Flash Media Server (FMS) 4.0.x:

  1. The first concept to understand is that FMS only responds to RTMPx requests and it is the Apache modules that enables HDS.
    • FMS only responds to RTMP/E, RTMPS, RTMPT/E, and RTMFP
    • The Apache modules respond to the HDS requests (.f4m, .f4f, .bootstrap, etc.)
    • Apache and FMS do not communicate for HDS:
      • FMS creates the HDS content in the specified directory
      • The Apache modules will retrieve the content from that directory to deliver to the client

  2. Disable the FMSEdge proxy and bind Apache to port 80:
    • By default FMS 4.0.x installer will bind the FMSEdge process to port 80 and 1935.
      • Binding to port 80 allows FMS to accept RTMPT (RTMP over HTTP) on that port. If you choose the optional Apache install, then the installer binds Apache to port 8134. All non-RTMP requests are proxied from the FMSEdge process over to Apache on port 8134.
      • FMSEdge proxying can cause issues and performance bottlenecks for HDS.
    • To disable FMSEdge proxy:
      • For new installs, only choose port 1935 for the FMS server port
      • For existing installs, make the following changes in $fms_root/conf/fms.ini:
        • Set ADAPTOR.HOSTPORT value to 1935
        • Clear the HTTPPROXY.HOST value
    • Bind Apache to port 80
      • For new installs, enter 80 for the Apache HTTP Server port
      • For existing installs, edit $fms_root/Apache2.2/conf/httpd.conf:
        • Either modify the existing Listen property or add a new one for port 80: e.g. Listen 80
  3. When streaming multiple bit rate (MBR) stream sets, ensure Absolute Time Code (ATC) is enabled on FMS and in the encoder. ATC is synonymous with Linear TimeCode (LTC) and ensures that all incoming live streams are moving forward and in synch based on an absolute clock:
    • To enable ATC in FMS set the Application>StreamManager>Live>AssumeAbsoluteTime tag to true in Application.xml. For more details on ATC settings in FMS 4.0.x see the Developer's guide: http://adobe.ly/jzmTwb.
      • ATC is enabled by default for the livepkgr application.
    • To enable ATC for Flash Media Live Encoder (FMLE) set the flashmedialiveencoder_config/mbrconfig/streamsynchronization/enable tag in the config.xml to true. For more details see the Developer's guide: http://adobe.ly/k49s7w.
    • Check third-party encoder documentation for LTC functionality.
  4. To reduce latency of writing the segment files (.f4f) to disk, ensure the Server>ResourceLimits>RecBuffer>MaxFlushTime tag in Server.xml is set to 1. See the Developer's guide for more details: http://adobe.ly/lr8cd8.
     
  5. The default HDS application is livepkgr. You can use the livepkgr/main.asc file in other application paths. However, the basic server-side actionscript (SSAS) syntax for creating HDS streams is: [code]var s = Stream.get("f4f:"+streamObj.name); s.record[/code]
     
  6. HDS requires both a stream name and a live event name:
    • FMS uses the stream name to create folders in the applicationName/streams/appInstance that contain the segment (.f4f), bootstrap (.bootstrap), index (.f4x), and other HDS related files;
    • FMS associates the live event name with a folder in applicationName/events/appInstance that contains the Event.xml, Manifest.xml, and stream record file (.stream)
      • Note: The applicationName/events folder is a sibling to the default applicationName/streams folder. The events folder is only used for Live events; the streams folder contains HDS content for both Live and VOD events.
      • Note: You must create the desired event folder before publishing to FMS. In other words, if you want to publish to an event called "foo", then you must create the applicationName/events/_definst_/foo folder. The default liveevent event folder is created for you in the default livepkgr application.
      • Note: The .stream file is a text file containing a pointer to the physical location of the HDS content (in the applicationName/streams/appInstance/streamName). For more details on the stream record files see the Developer's guide: http://adobe.ly/lMVDd9.
    • There are two ways to specify the desired live event name:
      1. If using the default livepkgr application script (main.asc), pass the adbe-live-event param with the stream name: e.g. livestream%i?adbe-live-event=foo.
        • Note: If the adbe-live-event param is missing the SSAS will use the stream name value as the event name. When using a single bit rate (SBR) stream, the stream name can be used as the event name, so the adbe-live-event param is not required. However, MBR streams require an event name to associate the stream names in a set. You must pass the adbe-live-event param with the stream name from the encoder.
      2. If coding a custom application, use the Stream.liveEvent property in the Application.onPublish event. For more details see the SSAS Language Reference: http://adobe.ly/ism7xb.
    • See the Developer's guide for more details on live events: http://adobe.ly/kZfDcW.
  7. Understanding the HDS URL syntax:
    • For SBR streams: http:////events//events///.f4m
      • For example: http://localhost/live/events/livepkgr/events/_definst_/liveevent/livestream.f4m
    • For MBR streams: http:////events//events//.f4m
      • For example: http://localhost/live/events/livepkgr/events/_definst_/liveevent.f4m
    • See the Live Packager tutorial in the Developer's guide for more details: http://adobe.ly/pDkaAP
  8. Set the live packager configuration the settings in Event.xml:
    • For most use cases the fragment duration settings are the most important. There are two ways to determine fragment duration: frame-based and time-based (default):
      1. Frame-based options
        • Use for CBR encoded streams
        • FrameRate -- set this to the encoder's frames per second (FPS) value (e.g. 29.97)
        • FramesPerKeyframeInterval -- set this by calculating the keyframe interval * fps (e.g. 4 * 29.97 ~= 120)
        • KeyframeIntervalsPerFragment -- use the keyframe interval value (e.g. 4)
        • FramePrecision -- use the default which is 1
      2. Time-based option
        • Use for VBR encoded streams
        • FragmentDuration -- Use the keyframe interval value in milliseconds (default is 4000)
      • Use the appropriate fragment duration options for your encoding type: CBR or VBR. If you are not sure of the encoding type, use the time-based settings.
      • If neither frame-based or time-based options are specified, the time-based option (FragmentDuration) default is used
    • Configure the SegmentDuration option
      • Segment files (F4Fs) can contain multiple fragments. The SegmentDuration option determines the number of F4F files that are created.
      • The SegmentDuration value (in milliseconds) should be a multiple of the FragmentDuration (or keyframe interval if using frame-based options) to ensure fragments are not written between two segments. For example, using the default FragmentDuration of 4000, set SegmentDuration to 40000 to create a 10 fragments per segment file (F4F).
      • The default value is 0 (zero), which means all fragments are written in a single F4F file
    • See the Live Packager reference in the Developer's guide for more details: http://adobe.ly/qWH5ge.
  9. Manifest.xml settings:
    • Ensure proper namespace usage:
    • The media tag bitrate attribute
      • set the value to the sum of the audio, video (and data if present) bitrate values in the stream. For example, if audio bitrate = 64 and video bitrate = 100, then set the bitrate value to 164 (64+100): [code][/code]
  10. HDS content TTL settings:
    • The .f4m and .bootstrap files are continuously updated during the live event. For smooth playback, ensure the stale files expire within the update timeframe (i.e. fragment duration).
    • Set the time-to-live (TTL) setting for the .f4m and .bootstrap files to approximately half of the fragment duration. For example, if the fragment duration is 4 seconds, then use a 2 second TTL value for .f4m and .bootstrap files.
    • TTL settings are set in the Apache httpd.conf

Comments (0) | Print | Send | del.icio.us | Digg It! | Linking Blogs
TweetBacks
There are no TweetBacks for this entry.
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Welcome to Sarge's personal blog A green acorn

Previous Month May 2012 Next Month

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Subscribe
Enter your email address to subscribe to this blog.