UWP中的视频解码



我有一个可以播放.m3u8文件的应用程序。然而,当用MPEG 1/2 (mpgv)编码视频时,它只显示空白屏幕。当打开像H.264这样的视频时,一切都很好。怎么了?

这里的代码:

using Microsoft.Media.AdaptiveStreaming;

//Listing: MainPage.xaml.cs -> class
private MediaExtensionManager extensions;
private PropertySet propertySet;
private IAdaptiveSourceManager adaptiveSourceManager;

//Listing: MainPage.xaml.cs -> class -> constructor
propertySet = new PropertySet();
extensions = new MediaExtensionManager();
adaptiveSourceManager = AdaptiveSourceManager.GetDefault();
propertySet["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = adaptiveSourceManager;
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/x-mpegurl", propertySet);
extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "video/mp2t", propertySet);
extensions.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", propertySet);

//Listing -> MainPage.xaml.cs -> OnNavigatedTo method
//Getting manifest.m3u8
var link = new Uri("path_to_remote_m3u8_file");
Player.Source = link;
Player.Play();

//Listing: MainPage.xaml
<MediaElement x:Name="Player" />

通常,在.m3u8中,我们有.ts文件的列表。但用H.264编码的可以播放,用MPEG-1MPEG-2编码的不能播放。

我想我需要为extensions添加更多的处理程序,或者我应该为Microsoft Player Framework添加处理程序,但他们没有用于windows 10的Dash plugin,所以按照这个示例,我无法实现结果。或者FFmpeg?

Windows 10不支持MPEG2视频编解码器。

尽管如此,Windows 10本身确实支持

  • HLS

  • MPEG DASH(实时档案)

如果您使用适用于Windows 10的平滑流媒体客户端SDK,它也支持平滑流媒体。

你使用了一个链接到我的博客,它与Windows 8.1有关,而不是与Windows 10有关。你会在我的github上找到一个通用视频播放器的示例,支持DASH、HLS和平滑流媒体+PlayReady DRM:https://github.com/flecoqui/Windows10/tree/master/Samples/UniversalMediaPlayer

此示例应用程序与运行Windows 10的PC、平板电脑、手机和XBOX One兼容。

如果你想播放MPEG2的内容,也许你可以使用VLC。VLC确实支持MPEG2编解码器。尝试VLC 3.0夜间构建
http://nightlies.videolan.org/build/win32/
VLC3.0应该很快就会RTM。

如果我回答了你的问题,请告诉我

最新更新