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 ...
随机推荐
- C++ 中超类化和子类化
超类化和子类化没有具体的代码,其实是一种编程技巧,在MFC和WTL中可以有不同的实现方法. 窗口子类化: 原理就是改变一个已创建窗口类的窗口过程函数.通过截获已创建窗口的消息,从而实现监视或修改已创建 ...
- 【转载】通过JDBC对MySQL数据库的增删改查
通过JDBC进行简单的增删改查(以MySQL为例) 目录 前言:什么是JDBC 一.准备工作(一):MySQL安装配置和基础学习 二.准备工作(二):下载数据库对应的jar包并导入 三.JDBC基本操 ...
- Qt qss 使用
1.在资源文件建立一个qss文件.如blue.qss 2. 调用 #include "mainwindow.h" #include <QApplication> #in ...
- Effective C++ -----条款49:了解new-handler 的行为
set_new_handler允许客户指定一个函数,在内存分配无法获得满足时被调用. Nothorw new 是一个颇为局限的工具,因为它只适用于内存分配:后继的构造函数调用还是可能抛出异常.
- zookeeper集群搭建(windows环境下)
本次zk测试部署版本为3.4.6版本,下载地址http://mirrors.cnnic.cn/apache/zookeeper/ 限于服务器个数有限本次测试了两种情况 1.单节点方式:部署在一台服务器 ...
- maven加载本地lib下的jar包
1.本地lib下有jar 2.命令: mvn install:install-file -Dfile=juh-3.0.1.jar -DgroupId=org.openoffice -Dartifact ...
- 用window.print()打印指定div里面的内容(转载的)
用window.print()打印指定div里面的内容 今天客户让添加个打印证照功能,直接用window.print()打印的是整个页面,而用以下方法就可以只打印证明了 <!--window.p ...
- 【leetcode】Gray Code (middle)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- 【python】入门学习(三)
for循环 for i in range(): #注意冒号 range中默认从0开始 或者从指定的数字开始 到给定数字的前一个数字结束 递增递减皆是如此 for循环提供变量的自动初始化 for i ...
- Linux 命令执行结果输出到屏幕的同时写入到文件中
tee命令可以做到这一点: 例:ls -al /home | tee log 就可以把命令输出的内容显示在屏幕上的同时也输出至文件log.