How to play H264 stream with SilverLight?

I have a H264 stream (IIS - smooth streaming) that I would like to play with SilverLight. Obviously, SilverLight can do this, but how?

Note: VC-1 stream can be played by SilverLight, but H264 is not.

I can also provide a stream and any additional information. The H264 encoder is the one installed in the Media Foundation (MFT). The same goes for VC-1, which works (although it is not possible to create equal chunks for smooth streaming, because forcing a keyframe to insert makes the video shake.

EDIT: MPEG2VIDEOINFO values โ€‹โ€‹for H264:

MPEG2VIDEOINFO values โ€‹โ€‹for H264

+7
video-streaming silverlight ms-media-foundation smooth-streaming
source share
2 answers

Just to guess. Based on your question 18009152. I assume that you are encoding h.264 using the application bitstream format. According to the comments, you cannot tell the encoder to use the AVCC format. Therefore, you must perform this conversion manually (Appendix B will NOT work in the ISO container). You can do this by looking for start codes in your AVC stream. The start code is 3 or 4 bytes (0x000001, 0x00000001). You get the NALU length by defining the next start code or end of stream. Reset the startup code (throw it away) and in its place write the size of the NALU at the 32-bit integer large end. Then write this data to the container. To be clear, this is done on video frames that exit the encoder. Additional data is a separate step that appears to be largely determined (other than NALUSizeLength). Since we use an integer of 4 bytes to write NALU sizes, you MUST set NALUSizeLength to 4.

+7
source share

Silverlight 3 can play H264 files. Use MediaStreamSource for this.

Here is a description of the interface: http://msdn.microsoft.com/en-us/library/system.windows.media.mediastreamsource(v=vs.95).aspx

In addition, this blog post is related to H264 playback using Silverlight 3: http://nonsenseinbasic.blogspot.ru/2011/05/silverlights-mediastreamsource-some.html This will help you with other problems that may arise.

-2
source share

All Articles