• How to achieve the lowest latency from capture to playback

    This article describes how to set up an application for streaming to achieve the lowest possible latency from video capture to playback.

    Note: For use with Wowza Media Server 2.0.0 or later.

    Configuration


    1. Install Wowza Media Server.

    2. Create a new Wowza Media Server application for streaming:

      1. Create the folder [install-dir]/applications/live.

      2. Create the folder [install-dir]/conf/live and copy the file [install-dir]/conf/Application.xml to this new folder.

      3. Open the the newly copied [install-dir]/conf/live/Application.xml file in a text editor and change the Streams/StreamType property value to live-lowlatency.


    On the player side, it's important that the NetStream.setBufferTime() method is set to zero (in Actionscript 3 use "NetStream.bufferTime = 0;"). This will give you the lowest possible latency on the playback side.

    Note: When using JW Player, the buffer length is set using the bufferLength parameter. See How to use LongTail JW Player 6 with Wowza Media Server.

    Note: Although zero will give you the best possible latency, it might not give you the smoothest playback. So you may need to increase the buffer time to a value slightly greater then zero (such as .1 or .25). When using H.264-encoded video, we've found that any buffer setting greater then zero introduces a latency of at least 2-3 seconds with 30 fps video (and even higher at lower frame rates). This seems to be a player issue.

    When running with NetStream.setBufferTime set to zero, you can often see lower frame rates due to the way the player renders the frames immediately. You can sometimes smooth playback by decreasing the flushInterval property value. You can do this by editing the [install-dir]/conf/[application]/Application.xml file and adding the following property to the Streams/Properties container (be sure to get the correct container as there are several in the Application.xml file):
    Code:
    <Property>
    	<Name>flushInterval</Name>
    	<Value>25</Value>
    	<Type>Integer</Type>
    </Property>
    <Property>
    	<Name>onFlushNotifyClients</Name>
    	<Value>true</Value>
    	<Type>Boolean</Type>
    </Property>
    With this setting in place, the servers per-stream CPU load will increase. So you won't be able to handle as many concurrent sessions per server.

    Latency is also introduced into the process on the encoding side. We've found that you can achieve very low latency encoding using the Flash player's built-in encoding (Microphone and Camera). The built-in encoding system in the Flash player uses Sorenson Spark (a variant of H.263) for video and NellyMoser ASAO or Speex for audio. To achieve low latency, it's important that you configure your encoding to produce a reasonable quality at the lowest possible bitrate. The VideoChat example that ships with Wowza Media Server is a good example of how to use the built-in Flash encoder to produce a low latency stream.

    Increasing the frame rate and/or decreasing the key frame interval can improve playback time in some cases.

    Note: Both the NellyMoser ASAO and the Speex audio codecs use an encoding methodology that encodes a fixed number of samples per packet. Because of this, it's actually better to use a slightly higher sample rate to achieve lower latency since packets are generated more often per second. So we suggest that when you use the built-in Microphone to encode audio, set the Microphone.rate to 11KHz or 22KHz.



    Comments 13 Comments
    1. icevic1 -
      I set live application and I set

      Code:
      <Name>flushInterval</Name>
      <Value>2</Value>
      <Type>Integer</Type>
      and 
      <StreamType>live-lowlatency</StreamType>
      /etc/init.d/WowzaMediaServer restart

      --------------------------
      this change not affect my big delay in 25 sec.

      Need delay maxim to 2 sec
      I using flash playr11 and src http://wowserv:1935/live/livestream/manifest.f4m
    1. rrlanham -
      It is probably more to do with encoding, most likely key frame interval. Take a look at this article:

      http://www.wowza.com/forums/content....s-(Flash-HTTP)

      Read carefully, this calls for changing the encoding not just configuration.

      Richard
    1. icevic1 -
      if I use no http src, but rtmp://wowzser:1935/live the delay reduced to 5 sec What is the problem?

      I use Adobe live media encoder 3.2 if change format from vp6 to H.264 the delay is 35 sec
    1. rrlanham -
      5 seconds is a long time for RTMP. If the RTMP playback is taking 5 seconds, it is probably low FPS. Read the article you posted under.

      HTTP segmented streaming is high latency. Take a look at the article I showed you.

      Richard
    1. icevic1 -
      bitrate on video is 500 kbps
      video rate 30fps
      udio bitrate 48 kbps
      -------------------------
      http delay is 25 sec
      rtmp delay is 5 sec
      -----------------------
      all is big
      help me
    1. rrlanham -
      According to these articles FPS and key frame frequency is critical. This is what to focus on.

      Richard
    1. icevic1 -
      rtmp delay resolved!
      set flash player buffer to 0, delay reduced to 1 sec.

      http dealay is not resolvet
    1. rrlanham -
      Following this guide to improve Cupertino live stream latency.

      http://www.wowza.com/forums/content....rameters-(iOS)

      If your live stream has a 1 second key frame frequency, and you set cupertinoChunkDurationTarget to 1000 milliseconds, which is 1 second (default is 10000 milliseconds, 10 seconds), you can get down to 3 seconds or less.

      Richard
    1. majidkhan -
      Quote Originally Posted by icevic1 View Post
      rtmp delay resolved!
      set flash player buffer to 0, delay reduced to 1 sec.

      http dealay is not resolvet
      I am getting a delay of about 4 seconds. Where did you modify this flash player buffer parameter?
    1. salvadore -
      If you are using your own Flash player, or the example Flash player that ships with Wowza you have to edit the Actionscript code of the player, use NetStream.setBufferTime().

      if you are using JWPlayer you would modify the bufferLength parameter.

      Here is the tutorial:
      How to achieve the lowest latency from capture to playback

      Salvadore
    1. gentmat -
      Hi Salvadore,
      What is the file that i should modify , i am using the example LiveVideoStreaming-->FlashRTMPPlayer-->Player.html
      I have two other files there, live.fla and live.swf and i don't know which one i must modify and where to put NetStream.setBufferTime
      can you please tell explain by detail where to add the code
      Thanks.

      Quote Originally Posted by salvadore View Post
      If you are using your own Flash player, or the example Flash player that ships with Wowza you have to edit the Actionscript code of the player, use NetStream.setBufferTime().

      if you are using JWPlayer you would modify the bufferLength parameter.

      Here is the tutorial:
      How to achieve the lowest latency from capture to playback

      Salvadore
    1. rrlanham -
      Seems to be a duplicate here
    1. yee.woon2@gmail.com -
      Hi, I'm using Wowza Media Server 3.6.2. In video chat I have 3-4 seconds delay. I cant find flash encoder AS3 file to set key frame interval. I use a Module to set bufferTime but it didn't decrease the latency. Could you please help me?