MediaStreamAttributeKeys

MediaStreamAttributeKeys

我们正在尝试在WP7仿真器上使用MediaStreamSource播放H.264流。但是遇到3100错误的视频:

在Mp4MediaStreamSource的覆盖方法OpenMediaAsync中,将videoStreamAttribute VideoFourCC设置为“H264”:

Dictionary<MediaStreamAttributeKeys, string> videoStreamAttributes = new Dictionary<MediaStreamAttributeKeys, string>();
videoStreamAttributes[MediaStreamAttributeKeys.VideoFourCC] = "H264";
this.videoStreamDescription = new MediaStreamDescription(MediaStreamType.Video, videoStreamAttributes);

但是在OpenMediaAsync之后根本没有调用GetSampleAsync,MediaElement只是返回错误“3100 An error has created”,没有更多其他信息。即使设置了CodecPrivateData属性,也会发生同样的错误。

最佳答案

根据this的文章,您必须设置[MediaStreamAttributeKeys.CodecPrivateData]
以编解码器期望的格式([START_CODE] [SPS] [START_CODE] [PPS])

videoStreamAttributes[MediaStreamAttributeKeys.CodecPrivateData] = "000000012742000D96540A0FD8080F162EA00000000128CE060C88";

10-04 11:57