如何在 C# 中更改 WMV 文件的分辨率
我有一个 C# 应用程序,我希望能够读取 WMV 文件,然后以降低的分辨率/质量写出 WMV 文件。
有没有 C# 的内置库可以做到这一点?我需要 Windows Media Format SDK 吗? 有人有这方面的经验吗?
我可以使用 FFmpeg 之类的东西吗?
I have a C# application and I would like to be able to read in a WMV file and then write out a WMV file with reduced resolution/quality.
Are there any built-in libraries for C# that can do this? Do I need the Windows Media Format SDK?
Does anyone have experience with this?
Can I use something like FFmpeg for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须对文件进行解码和重新编码(=转码)才能执行此操作。这样做本质上会降低质量,因为您是在已经压缩的基础上工作的。
如果您需要高度控制,一种方法是使用 C# 的 DirectShow 包装器,即 DirectShow.NET。那么你只需要定义一个简单的转码图。
实际上,最简单的方法是使用 Expression Encoder (Windows Media 的后继者) Encoder),它有一个简单的托管 API,并且比集成 DirectShow 花费更少的精力来完成这项工作。
此处有一篇摘要文章。一个简单的转码作业如下所示(文章中的示例,仅更改了预设):
You will have to decode and re-encode ( = transcode) the file to do this. By doing so you will inherently reduce quality since you are working off an already compressed base.
One way to do it if you need a high degree of control is is with a DirectShow wrapper for C#, i.e. DirectShow.NET. then you just need to define a simple transcoding graph.
Actually the simplest way to do this is with Expression Encoder (the successor to Windows Media Encoder) which has a simple managed API and should do the job with much less effort than integrating DirectShow.
There's a summary article here. A simple transcoding job looks like this (sample from article, only presets changed):
我认为 .Net Framework 中没有任何类可以处理 WMV 文件转码。
但您可以安装 Windows Media 9 Encoder SDK 并用 C# 创建适当的对象来执行转换。请参阅CodeProject.com - 将 MP3、MPEG、AVI 转换为 Windows Media 格式为起点。即使该链接以非 WMV 文件开头,Windows Media Encoder 也不限制输入文件格式(至少当我使用 VBScript 编码批处理文件时)。
注意:如果您在 Vista 或 Win7 上使用 WM9Encoder,则可能需要修补程序 - 请参阅 TechNet - 在 Windows 7 上使用 Windows Media Encoder 9 Series 的问题
I don't think there are any classes in the .Net Framework which deal with transcoding WMV files.
But you can install the Windows Media 9 Encoder SDK and create appropriate objects in C# to do the conversion. See CodeProject.com - Convert MP3, MPEG, AVI to Windows Media Formats for a starting point. Even though that link starts with non-WMV files, the Windows Media Encoder doesn't restrict the input file format (at least when I've used the VBScript encoding batch file).
N.B If you use the WM9Encoder on Vista or Win7, you may need the hotfix - see TechNet - issues in using Windows Media Encoder 9 Series on Windows 7