简体   繁体   English

如何使用SilverLight播放H264流?

[英]How to play H264 stream with SilverLight?

I have an H264 stream (IIS - smooth streaming) that I would like to play with SilverLight. 我有一个H264流(IIS - 流畅的流),我想与SilverLight一起玩。 Apparently SilverLight can do it, but how? 显然SilverLight可以做到,但是怎么做?

Note: 注意:
the VC-1 stream can be played by the SilverLight, but H264 not. SilverLight可以播放VC-1流,但H264不能播放。

Also, I can provide a stream and any additional information required. 此外,我可以提供流和所需的任何其他信息。 H264 encoder is the one in Media Foundation (MFT). H264编码器是Media Foundation(MFT)中的编码器。 Same goes for the VC-1 that works (although is it impossible to create equal chunks for smooth streaming because forcing key-frame insertion makes video jerky. VC-1的工作方式也是如此(尽管无法为平滑流创建相同的块,因为强制关键帧插入会导致视频不稳定。

EDIT: MPEG2VIDEOINFO values for H264: 编辑:H264的MPEG2VIDEOINFO值:

H264的MPEG2VIDEOINFO值

Just a guess. 只是一个猜测。 Based on your question 18009152. I am guessing you are encoding h.264 using the annexb bitstream format. 基于您的问题18009152.我猜您使用annexb比特流格式编码h.264。 According to comments, you can not tell the encoder to use AVCC format. 根据评论,你不能告诉编码器使用AVCC格式。 Therefore, you must perform this conversion manually (Annex B WILL NOT work in an ISO container). 因此,您必须手动执行此转换(附录B不适用于ISO容器)。 You can do this by looking for start codes in your AVC stream. 您可以通过在AVC流中查找起始代码来执行此操作。 A start code is 3 or 4 bytes (0x000001, 0x00000001). 起始码为3或4个字节(0x000001,0x00000001)。 You get the length of the NALU by locating the next start code, or the end of the stream. 通过查找下一个起始代码或流的结尾,可以获得NALU的长度。 Strip the start code (throw it away) and in its place write the size of the NALU in a 32bit integer big endian. 剥离起始代码(扔掉它)并在其位置写入32位整数大端的NALU的大小。 Then write this data to the container. 然后将此数据写入容器。 Just to be clear, this is performed on the video frames that come out of the encoder. 需要明确的是,这是在编码器出来的视频帧上执行的。 The extra data is a separate step that appears you have mostly figure out (except for the NALUSizeLength). 额外的数据是一个单独的步骤,看起来你大部分已经弄明白了(除了NALUSizeLength)。 Because we uses a 4 byte integer to write the NALU sizes, you MUST set NALUSizeLength to 4. 因为我们使用4字节整数来写NALU大小,所以必须将NALUSizeLength设置为4。

Silverlight 3 can play H264 files. Silverlight 3可以播放H264文件。 Use MediaStreamSource for this. 为此使用MediaStreamSource

Here is the interface description: http://msdn.microsoft.com/en-us/library/system.windows.media.mediastreamsource(v=vs.95).aspx 这是界面描述: http//msdn.microsoft.com/en-us/library/system.windows.media.mediastreamsource(v = vs95).aspx

Also, this blog entry is related to H264 playing sing Silverlight 3: http://nonsenseinbasic.blogspot.ru/2011/05/silverlights-mediastreamsource-some.html It will help you with other issues that may arise. 此外,此博客条目与H264播放Silverlight 3相关: http//nonsenseinbasic.blogspot.ru/2011/05/silverlights-mediastreamsource-some.html它将帮助您解决可能出现的其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用MediaStreamSource播放来自matroska文件的h264帧? - How to use MediaStreamSource to play h264 frames coming from a matroska file? Silverlight播放器是否支持H264 / MultiView编码(3D)视频? - Does the Silverlight player support H264/MultiView Coding (3D) Videos? 您如何测试Silverlight是否可以播放流? - How do you test whether Silverlight can play a stream? Silverlight,在Silverlight Media Element中播放来自IP摄像机的视频流 - Silverlight, Play Video stream from IP camera in Silverlight Media Element 有没有一种方法可以从MIC流音频并在Silverlight中播放该流 - Is there a way to stream audio from MIC and play that stream in Silverlight 在Silverlight中无法找到某些H.264视频中的已下载数据 - Can't seek beyond downloaded data in some H.264 videos in Silverlight 如何在silverlight中播放swf文件? - How to play swf file in silverlight? 如何将链接转换为源以在Silverlight中流式传输? - How to convert link to source to stream in silverlight? 如何在Silverlight中播放* .mp4(本地-无服务器)? - How to play *.mp4 in Silverlight (locally - no server)? 如何在Silverlight中连续播放小声音文件? - How to play small sound file continuously in Silverlight?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM