Windows和Windows Phone应用终于可以使用FFmpeg了
(此文章同时发表在本人微信公众号“dotNET每日精华文章”,欢迎右边二维码来关注。)
题记:曾经在Windows Phone上想开发一个支持多种格式的媒体播放器是比较困难的一件事情,因为无法利用FFmpege这样的开源库。不过现在好了,微软提供了一个开源的FFmpegInterop解决了此问题。
由于WinRT和Windows Phone平台的限制,在上面的APP只能播放内置多媒体播放器支持的几种格式(比如WMV,MP4等),虽然这些格式还是能满足大部分情况。不过如果你打算开发一款格式支持更全面的播放器(或者你的软件打算播放一些额外的格式,比如mkv、flv和mov等),那么就比较分周折了,因为一些常用的开源多媒体库无法直接使用。就连VLC这样的著名软件都迟迟没有推出WP版本。
微软曾经发布了一系列编译指令来构建和WinRT兼容的FFmpeg。不过这样做会带来性能损耗。为了解决这个问题,微软最近在GitHub上发布了一个名为FFmpegInterop的开源库,解决了这个问题。这个开源库利用FFmpege来处理媒体内容,但回放使用Windows媒体框架。这种方式能够获得更好的性能,因为Windows媒体框架可以利用硬件加速。微软同时也发布了使用C#、C++和JavaScript编写的示例媒体播放器APP。
大致用法是:
- 创建一个FFmpegInterop对象,插接到XAML的MediaElement对象中或者WinJS的HTML5 Video组件中
- 使用FileOpenPicker打开一个本地文件,作为一个流传递给FFmpegInterop
上述使用步骤的C#代码类似如下:
1: // Instantiate FFmpeg object and pass the stream from opened file
2: IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read);
3: FFmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(readStream, false, false);
4:
5: // Pass MediaStreamSource to Media Element
6: mediaElement.SetMediaStreamSource(FFmpegMSS.GetMediaStreamSource());
更详细的用法可以通过“阅读原文”来了解。从原文地址中也可以找到该项目的GitHub地址。
(特别提醒,微软在GitHub上的主页还列出了很多开源项目,是个不容错过的宝藏。)
原文地址:http://blogs.windows.com/buildingapps/2015/06/05/using-ffmpeg-in-windows-applications/
Windows和Windows Phone应用终于可以使用FFmpeg了的更多相关文章
- Windows下使用Visual Studio 2010编译ffmpeg全过程
在visual studio 2010中调用ffmpeg http://blog.sina.com.cn/s/blog_4178f4bf01018wqh.html Windows下使用Visual S ...
- Installing the .NET Framework 3.5 on Windows 8, Windows 8.1 and Windows 10
Installing the .NET Framework 3.5 on Windows 8, Windows 8.1 and Windows 10 .NET Framework (current v ...
- 用C#创建Windows服务(Windows Services)
用C#创建Windows服务(Windows Services) 学习: 第一步:创建服务框架 创建一个新的 Windows 服务项目,可以从Visual C# 工程中选取 Windows 服务(W ...
- Memory Limits for Windows and Windows Server Releases
来源:https://msdn.microsoft.com/en-us/library/windows/desktop/aa366778(v=vs.85).aspx Limits on memory ...
- Notice to users of DB Query Analyzer in Windows 7, Windows 8 and Windows 10
UnlikeWinXP, VISTA, Windows2000, Windows Nt and Win98,Windows 7 / Windows 8 / Windows 10 select ...
- How to detect, enable and disable SMBv1, SMBv2, and SMBv3 in Windows and Windows Server
转自:https://support.microsoft.com/en-us/help/2696547/detect-enable-disable-smbv1-smbv2-smbv3-in-windo ...
- [转载]Memory Limits for Windows and Windows Server Releases
Memory Limits for Windows and Windows Server Releases This topic describes the memory limits for sup ...
- C# windows服务:创建Windows服务(Windows Services)的一般步骤
C#创建Windows服务(Windows Services) Windows服务在Visual Studio 以前的版本中叫NT服务,在VS.net启用了新的名称.用Visual C# 创建Wind ...
- [微软]The latest version of Windows is Windows Sandbox
The latest version of Windows is Windows Sandbox by Surur @mspoweruser Dec 19, 2018 at 1:40 GMT As h ...
随机推荐
- ubuntu 13.10 skype登不上问题
首先打开sources.list sudo gedit /etc/apt/sources.list 如果是13.10添加源: deb http://archive.canonical.com/ubun ...
- ios – 使用UINib加载xib文件实现UITableViewCell
xib文件的实质是xml,描述界面对象,每个对象都有一个很重要的属性,identity inspector面板中class属性,加载xib文件的时候实际上是实例化界面对象相对应的这些class. xi ...
- sharepoint的导航开发
2.来大体讲一下“导航” (1)全局导航 : 整个网站集的导航:(如果公司的网站有很多子网站,这时便会用到全局导航啦):贴一下主要代码: using Microsoft.SharePoint.Publ ...
- C#之设置无边框后如何移动窗体(转)
转载:http://www.cnblogs.com/techmango/archive/2012/03/31/2427523.html 第一种,利用windows的消息机制来实现: 首先﹐.定义鼠標左 ...
- struts2 校验数据的有效性 2种方式
Struts2的数据校验: 数据的校验分为客户端校验和服务器端两种: 客户端校验:JS完成的校验.(为了提升用户体验.减少用户的输入错误) 服务器端校验:在后台的校验.(必须的.) 手动编码进行校验: ...
- java.lang.UnsatisfiedLinkError: Couldn't load hyphenate_av from loader dalvik.system.PathClassLoader
android studio引入第三方库时报如下异常. 06-15 16:50:24.477 9497-9497/easemobim.test.com.easemobim E/AndroidRunti ...
- Nginx如何设置拒绝或允许指定ip访问
location ~ /druid/ { #deny 192.168.1.1; allow 192.168.1.1; deny all; proxy_pass http://127.0.0.1:808 ...
- Unity3d 用NGUI制作做新手引导的思路
一.先看下效果 Prefab结构 二.实现思路: 1.prefab上的Panel层级设置成较高 2.背景由5个UISprite拼接起来的,4个(L,R,U,D)当作遮罩,1个镂空(Hollow)当作点 ...
- Unity3D研究院之手游开发中所有特殊的文件夹(转)
这里列举出手游开发中用到了所有特殊文件夹. 1.Editor Editor文件夹可以在根目录下,也可以在子目录里,只要名子叫Editor就可以.比如目录:/xxx/xxx/Editor 和 /Edi ...
- 7.django之自定义分页记录
只是大概记录下步骤: 1.表结构: class UserProfile(models.Model): ''' 用户表 ''' user = models.OneToOneField(User,verb ...