How to publish a video file as a live stream

This article describes how to use the ServerListenerStreamDemoPublisher server listener to publish a video file as a live stream. The file will loop endlessly. This setup is very basic and static. More dynamic solutions are discussed in the following articles:

 

Add the following <ServerListener> to the <ServerListeners> list of [install-dir]/conf/Server.xml:

<ServerListener>
	<BaseClass>com.wowza.wms.module.ServerListenerStreamDemoPublisher</BaseClass>
</ServerListener>
Add the following property to the <Properties> container at the bottom of [install-dir]/conf/Server.xml:
<Property>
	<Name>streamDemoPublisherConfig</Name>
	<Value>appName=live,srcStream=mp4:sample.mp4,dstStream=myStream,sendOnMetadata=true</Value>
</Property>
You can publish multiple live streams by adding them to the property value as a list of entries delimited by the pipe (|) character. For example:
<Property>
	<Name>streamDemoPublisherConfig</Name>
	<Value>appName=live,srcStream=mp4:sample.mp4,dstStream=myStream,sendOnMetadata=true|appName=live,srcStream=mp4:sample.mp4,dstStream=myStream2,sendOnMetadata=true</Value>
</Property>
You can also publish a playlist of files by creating a text file in the [install-dir]/content folder with the .m3u8 file extension. This file should contain simple streams names on each line like this (for this example we will use the file name filelist.m3u8):
mp4:sample.mp4
mp4:file2.mp4
mp4:file3.mp4
To play this playlist, use a streamDemoPublisherConfig value like this:
<Property>
	<Name>streamDemoPublisherConfig</Name>
	<Value>appName=live,srcStream=m3u8:filelist.m3u8,dstStream=myStream,random=false,timeBetweenItems=250</Value>
</Property>
To configure a stream to play for 10 seconds, pause for 2 seconds, and then repeat, use a streamDemoPublisherConfig value like this:
<Property>
	<Name>streamDemoPublisherConfig</Name>
	<Value>appName=live,srcStream=mp4:sample.mp4,dstStream=myStream,random=true,publishDuration=10,publishRepeat=true,publishPauseTime=2</Value>
</Property>

Configuration Items 

  • appName - Application name, in the form application/appInstance (appInstance can be omitted).
  • vhostName - Virtual host (VHost) name. If omitted, the stream will be created for all VHosts.
  • dstStream - Destination stream name.
  • srcStream - Name of video file to stream as live content (MP4, MP3, FLV, and M3U8 files are supported).
  • sendOnMetadata - If true, instructs the publisher to send onMetadata events.
  • repeat - If true, the file or playlist is repeated.
  • timeBetweenItems - Time, in milliseconds, between playlist items (default is 80 milliseconds).
  • random - If true and if using an M3U8 playlist, the items in the playlist are streamed in a random order.
  • speed - Playback speed. This is a floating point value that can be negative (default is 1.0, be careful with this one - may not work in all cases). 
Note: In Wowza Streaming Engine™ 4.4.0, we improved ServerListenerStreamDemoPublisher by adding and modifying the following configuration items:
  • Renamed repeat to playlistRepeat (repeat is also supported). If true, the file or playlist items are repeated.
  • Added publishDuration - Time, in seconds, the stream will publish (format: HH:MM:SS.mmm).
  • Added publishRepeat - If true, the stream is re-published in a loop after the publishDuration time has elapsed (publishDuration must be greater than zero, default is false).
  • Added publishPauseTime - If publishRepeat is set to true, the time, in seconds, the stream pauses before being republished (format: HH:MM:SS.mmm, default is 1 second).

If you're having problems or want to discuss this article, post in our forum.