• How to lock multi-bitrate streams on live stream repeater edge

    This article describes how to ensure that each origin stream in a multiple-bitrate stream on a Wowza live stream repeater edge server is locked so that they are aligned for proper switching.

    Note: These streams must be aligned at the source. The technique described in this article doesn't fix mis-alignment in the source. For more information about how to debug stream alignment on the origin server, see How to debug encoder multi-bitrate keyframe alignment.

    Configuration


    1. Configure an origin application name liveorigin. Change the StreamType property in [wowza-origin-install-dir]/conf/liveorigin/Application.xml to live.
      <StreamType>live</StreamType>
    2. Leave the LiveStreamPacketizers property empty in [wowza-origin-install-dir]/conf/liveorigin/Application.xml. If it's not already empty, remove any packetizers.
      <LiveStreamPacketizers></LiveStreamPacketizers>
    3. Configure an edge application named liveedge. Change the StreamType property in [wowza-edge-install-dir]/conf/liveedge/Application.xml to live.
      <StreamType>live</StreamType>
      Note: Don't use the liverepeater-edge stream type here because we will start the streams using [wowza-edge-install-dir]/conf/StartUpStreams.xml using MediaCaster type liverepeater. This will ensure that the MediaCaster system has a lock on each stream.

    4. Add the regular live stream packetizers to the LiveStreamPacketizers property in [wowza-edge-install-dir]/conf/liveedge/Application.xml. This enables packetizing to happen on the edge instead of the origin.
      <LiveStreamPacketizers>cupertinostreamingpacketizer,smoothstreamingpacketizer,sanjosestreamingpacketizer</LiveStreamPacketizers>
    5. Assume that there are 3 live streams that are keyframe-aligned versions with different bitrates. You might use either a live encoder that has this capability or Wowza Transcoder. I will use the Wowza Transcoder and the default transrate.xml template. The source stream will be named livestream. I will need three .stream files on the edge in the edge content folder ([wowza-edge-install-dir]/content).

      file: [wowza-edge-install-dir]/content/livestream_source.stream
      contents: rtmp://[wowza-origin-address]/liveorigin/livestream_source

      file: [wowza-edge-install-dir]/content/livestream_360p.stream
      contents: rtmp://[wowza-origin-address]/liveorigin/livestream_360p

      file: [wowza-edge-install-dir]/content/livestream_160p.stream
      contents: rtmp://[wowza-origin-address]/liveorigin/livestream_160p

    6. Next we need a .smil file on the edge. It's placed in the [wowza-edge-install-dir]/content folder alongside the three .stream files. If you're using Wowza Transcoder, you can use the method describe in How to create and play SMIL files with streams created by Wowza Transcoder to generate a SMIL file. With some minor adjustments (adding .stream to the stream names), this is the SMIL file that I copied to the [wowza-edge-install-dir]/content folder:
      <smil>
      <head></head>
      <body>
      	<switch>
      		<video src="mp4:livestream_source.stream" system-bitrate="567594" width="424" height="240">
      			<param name="audioBitrate" value="107450" valuetype="data"/>
      			<param name="videoBitrate" value="460144" valuetype="data"/>
      			<param name="videoCodecId" value="avc1.66.30" valuetype="data"/>
      			<param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
      		</video>
      		<video src="mp4:livestream_360p.stream" system-bitrate="957450" width="636" height="360">
      			<param name="audioBitrate" value="107450" valuetype="data"/>
      			<param name="videoBitrate" value="850000" valuetype="data"/>
      			<param name="videoCodecId" value="avc1.77.30" valuetype="data"/>
      			<param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
      		</video>
      		<video src="mp4:livestream_160p.stream" system-bitrate="307450" width="282" height="160">
      			<param name="audioBitrate" value="107450" valuetype="data"/>
      			<param name="videoBitrate" value="200000" valuetype="data"/>
      			<param name="videoCodecId" value="avc1.66.12" valuetype="data"/>
      			<param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
      		</video>
      	</switch>
      </body>
      </smil>
      If you're not using Wowza Transcoder, you can make a simple SMIL file that omits the param lines with codec info (this is optional). See How to create and play SMIL files with streams created by Wowza Transcoder for more information.

    7. Finally, we need to start each of the streams using the [wowza-edge-install-dir]/conf/StartUpStreams.xml so that they are started when the edge server starts.
      <Root>
      	<StartupStreams>
      
      		<StartupStream>
      			<Application>liveedge/_definst_</Application>
      			<MediaCasterType>liverepeater</MediaCasterType>
      			<StreamName>livestream_source.stream</StreamName>
      		</StartupStream>
      
      		<StartupStream>
      			<Application>liveedge/_definst_</Application>
      			<MediaCasterType>liverepeater</MediaCasterType>
      			<StreamName>livestream_360p.stream</StreamName>
      		</StartupStream>
      
      		<StartupStream>
      			<Application>liveedge/_definst_</Application>
      			<MediaCasterType>liverepeater</MediaCasterType>
      			<StreamName>livestream_160p.stream</StreamName>
      		</StartupStream>	
      
      	</StartupStreams>
      </Root>
    8. Start the origin, and then publish a stream named livestream to the liveorigin application, or a stream with Stream Manager. If the liveorigin application is configured with Wowza Transcoder using the default transrate.xml template, the filenames will match the above steps. If you're starting a stream with Stream Manager, you must use the StreamNameAlias AddOn to use the name livestream, or you can use a .stream file (livestream.stream) on the origin and then adjust the stream names in the above examples.

      Note: The live stream must contain H.264 video and AAC or MP3 audio.

    9. Start the edge. The [wowza-edge-install-dir]/conf/StartUpStreams.xml will run, loading and locking the 3 origin streams, which are now ready to play with cupertinostreaming to Apple iOS devices, smoothstreaming to Silverlight, and sanjosestreaming to Flash HTTP (OSMF) clients.


    Playback


    To play using Adobe Flash Player (San Jose/Adobe HTTP Dynamic Streaming)

    Wowza Media Server 3.5.0 and later
    Double-click [install-dir]/examples/LiveVideoStreaming/FlashHTTPPlayer/player.html, enter the information below, and then click the Connect button.

    Wowza Media Server 3.1.2 and earlier
    double-click [install-dir]/examples/LiveVideoStreaming/clientOSMF/bin-release/LiveOSMFPlayer.html, enter the information below, and then click the Play button.

    Stream: http://[wowza-edge-address]:1935/liveedge/smil:livestream.smil/manifest.f4m
    Note: The stream can only be played from an OSMF-based Flash player that's embedded in a webpage.

    Note: To play the stream from a remote computer, copy the contents of the FlashHTTPPlayer or clientOSMF/bin-release folders to a web server.

    To play using an Apple iOS device (Cupertino/Apple HTTP Live Streaming)

    Enter the following URL into the Safari web browser on the device:
    http://[wowza-edge-address]:1935/liveedge/smil:livestream.smil/playlist.m3u8
    Note: The Apple iPhone 3GS (and older) and iPod touch devices require that video be encoded using H.264 format (Baseline profile level 3 or lower) and AAC or MP3 stereo audio.

    Note: This stream can also be played using the Safari web browser or QuickTime 10.x on a computer running OS X Snow Leopard version 10.6 or later.

    To play using Microsoft Silverlight (Smooth Streaming)

    Wowza Media Server 3.5.0 and later
    Double-click [install-dir]/examples/LiveVideoStreaming/SilverlightPlayer/player.html, enter the information below, and then click the Connect button.

    Wowza Media Server 3.1.2 and earlier
    Double-click [install-dir]/examples/LiveVideoStreaming/clientSilverlight/Default.html, enter the information below, and then click the Play button.

    http://[wowza-edge-address]:1935/liveedge/smil:livestream.smil/Manifest
    Note: The Microsoft Silverlight player requires that both audio and video be present for playback. For live streaming only, the keyframe frequency (which can be set directly in some encoders or is gop/fps) must be between 1 and 4 seconds (2 seconds is recommended). Anything greater than 4 seconds may cause playback to freeze.

    Note: To play the stream from a remote computer, copy the contents of the Silverlightplayer or clientSilverlight folders to a web server.