我是 Microsoft Smooth Streaming 的新手,对合成清单的制作有疑问。
按照这里的指导。
我能够制作在 Silverlight 播放器中播放的单个剪辑元素的复合清单。
但是,当我尝试从其他视频添加更多剪辑时,播放器停止工作并且没有给出错误信息。
而且我都是手工完成的。当我尝试使用 Expression Encoder 4 Pro 创建这样的视频时,我得到的是普通.ismc
文件而不是.csm
文件。
我的问题是:
制作包含来自不同视频的剪辑的复合清单的最佳方法是什么?编码这些视频时是否有任何规范?还是复合清单的支持对视频格式有任何限制?
最后一个是:有没有一种简单的方法来调试它(比如验证我的 .csm 文件)?
编辑我自己的解决方案:
看起来没人关心这个,但既然我终于解决了这个问题,我把它写在这里是为了节省别人的时间。
为了调试复合清单,我在 Visual Studio 中构建了一个简单的 Silverlight 应用程序,并添加了一个简单的函数来报告错误:
MainPage.xaml.cs:
public MainPage()
{
InitializeComponent();
this.SmoothPlayer.SmoothStreamingErrorOccurred += new EventHandler<SmoothStreamingErrorEventArgs>(SmoothPlayer_SmoothStreamingErrorOccurred);
}
public void SmoothPlayer_SmoothStreamingErrorOccurred(object sender,
SmoothStreamingErrorEventArgs e)
{
MessageBox.Show("Error: " + e.ErrorCode + "; " + e.ErrorMessage);
}
我发现这个网页很有用。
你需要使用:
<c t="", d"">
代替
<c d="">
您必须正确计算ClipBegin
和ClipEnd
值。
下面是在 python 中将 a 转换为 a 的示例代码.ismc
(.csm
假设下面的 ism 是清单 xml 内容的 xml.etree.ElementTree 对象表示):
def ism2csm(url, ism):
if ism is None: return csm
csm = xml.Element('SmoothStreamingMedia', {'MajorVersion':'2', 'MinorVersion':'1', 'Duration':ism.attrib.get('Duration')})
clip = xml.Element('Clip', {'Url':url, 'ClipBegin':'0','ClipEnd':'0'})
csm.append(clip)
for stream_index in ism.iter('StreamIndex'):
clip.append(stream_index)
for stream_index in clip.iter('StreamIndex'):
t = 0
last_c = None
for c in stream_index.iter('c'):
c.attrib['t'] = str(t)
t += int(c.attrib.get('d'))
if last_c is not None: del last_c.attrib['d']
last_c = c
if clip.attrib.get('ClipEnd') == '0':
clip.attrib['ClipEnd'] = str(t)
return csm