可以使用此版本的Wowza安排播放列表吗?
我试过文章https://www.wowza.com/forums/content.php?145-How-to-schedule-streaming-with-Wowza-Streaming-Engine-(ServerListenerStreamPublisher)上传模块集合,但没有成功,日志上没有记录有关播放列表的任何数据。
/conf/live/Application.xml
<Module>
<Name>streamPublisher</Name>
<Description>Playlists</Description>
<Class>com.wowza.wms.plugin.collection.module.ModuleStreamPublisher</Class>
</Module>
<Property>
<Name>streamPublisherSmilFile</Name>
<Value>playlists.smil</Value>
<Type>String</Type>
</Property>
答案 0 :(得分:0)
我在Wowza 2.2.3版实例上测试了这个模块,它对我来说很好用,访问日志显示如下:
ServerListenerStreamPublisher Scheduled: Stream1 for: 2015-04-07
ServerListenerStreamPublisher stream is **NOT** set to not repeat, setUnpublishOnEnd: true Stream1
ServerListenerStreamPublisher scheduled playlist: Stream1 on stream: Stream1 for:Tue Apr 07
ServerListenerStreamPublisher Scheduled stream is now live: Stream1
ModuleStreamPublisher.onAppStart: [live/_definst_]: DONE!
Stream.switch[live/_definst_/Stream1]: index: 0 name:mp4:sample.mp4 start:5 length:5
此模块可以在服务器级别或应用程序级别上完成。不同之处在于启动输出流,在服务器级别实现自动连接预定的播放列表,而在应用程序级别,您需要手动连接包含计划的SMIL文件。
要在应用程序级别进行连接:
确保playlists.smil存在于您的内容/目录中并具有正确的权限。示例SMIL文件:
<smil>
<head></head>
<body>
<stream name="Stream1"></stream>
<playlist name="pl1" playOnStream="Stream1" repeat="true" scheduled="2015-04-07 16:00:00">
<video src="mp4:sample.mp4" start="5" length="5"/>
<video src="mp4:elephantsdream_750.mp4" start="50" length="25"/>
<video src="mp4:sample.mp4" start="0" length="150"/>
</playlist>
</body>
</smil>
通过Stream Manager(http://wowzaIP:8086/streammanager)将playlists.smil连接到您的实时应用程序。您的播放流名称,如果您在应用程序“live”上使用上述示例,则为rtmp:// wowzaIP:1935 / live / Stream1。
此模块的基础是Stream类,因此您也可以选择构建自己的模块。这是一个非常类似于上面的简单的(除了它在服务器重启时自动启动,因为它被添加为服务器侦听器)。构建模块后,将其添加到conf / Server.xml到ServerListeners容器。我还在版本2.2.3上测试了这个模块,它对我有用。
package com.wowza.wms.example.serverlistener;
import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.server.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.stream.publish.*;
import com.wowza.wms.application.*;
public class StreamPublisherDemo implements IServerNotify2 {
public void onServerConfigLoaded(IServer server)
{
}
public void onServerCreate(IServer server)
{
}
public void onServerInit(IServer server)
{
IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
IApplication app = vhost.getApplication("live");
IApplicationInstance appInstance = app.getAppInstance("_definst_");
Stream stream1 = Stream.createInstance(vhost, "live", "Stream1");
stream1.play("mp4:sample.mp4", 5, 5, true);
stream1.play("mp4:sample.mp4", 50, 5, false);
stream1.play("mp4:sample.mp4", 150, 5, false);
stream1.addListener(new StreamListener(appInstance));
Stream stream2 = Stream.createInstance(vhost, "live", "Stream2");
stream2.play("mp4:sample.mp4", 0, -1, true);
stream2.addListener(new StreamListener(appInstance));
}
public void onServerShutdownStart(IServer server)
{
}
public void onServerShutdownComplete(IServer server)
{
}
class StreamListener implements IStreamActionNotify
{
StreamListener(IApplicationInstance appInstance)
{
}
public void onPlaylistItemStop(Stream stream, PlaylistItem item)
{
WMSLoggerFactory.getLogger(null).info("Item Stopped: " + item.getName() + "on Stream: " + stream.getName());
}
public void onPlaylistItemStart(Stream stream, PlaylistItem item)
{
WMSLoggerFactory.getLogger(null).info("Item Started: " + item.getName() + "on Stream: " + stream.getName());
}
}
}