如何在 .Net 中获取视频缩略图?

发布于 2024-07-06 02:45:59 字数 355 浏览 6 评论 0原文

我正在寻求实现一个从输入视频中检索单个帧的函数,因此我可以将其用作缩略图。

沿着这些思路的东西应该有效:

// filename examples: "test.avi", "test.dvr-ms"
// position is from 0 to 100 percent (0.0 to 1.0)
// returns a bitmap
byte[] GetVideoThumbnail(string filename, float position)
{
}

有谁知道如何在.Net 3.0中做到这一点?

正确的解决方案将是该功能的“最佳”实现。 避免选择空白帧的奖励积分。

I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail.

Something along these lines should work:

// filename examples: "test.avi", "test.dvr-ms"
// position is from 0 to 100 percent (0.0 to 1.0)
// returns a bitmap
byte[] GetVideoThumbnail(string filename, float position)
{
}

Does anyone know how to do this in .Net 3.0?

The correct solution will be the "best" implementation of this function.
Bonus points for avoiding selection of blank frames.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

心作怪 2024-07-13 02:45:59

我最终推出了自己的独立类(使用我描述的单一方法),可以在此处查看源代码媒体浏览器是 GPL,但我很高兴我为该文件编写的代码成为公共领域。 请记住,它使用 directshow.net 项目中的互操作,因此您必须清除该部分与他们一起编码。

此类不适用于 DVR-MS 文件,您需要为这些文件注入直接显示过滤器。

I ended up rolling my own stand alone class (with the single method I described), the source can be viewed here. Media browser is GPL but I am happy for the code I wrote for that file to be Public Domain. Keep in mind it uses interop from the directshow.net project so you will have to clear that portion of the code with them.

This class will not work for DVR-MS files, you need to inject a direct show filter for those.

—━☆沉默づ 2024-07-13 02:45:59

这个项目可以解决 AVI 的问题: http://www.codeproject.com/ KB/audio-video/avifilewrapper.aspx

任何其他格式,您可以查看 directshow。 有一些项目可能会有所帮助:
http://sourceforge.net/projects/directshownet/
http://code.google.com/p/slimdx/

This project will do the trick for AVIs: http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx

Anything other formats, you might look into directshow. There are a few projects that might help:
http://sourceforge.net/projects/directshownet/
http://code.google.com/p/slimdx/

司马昭之心 2024-07-13 02:45:59

1- 从以下位置获取最新版本的 ffmpeg.exe: http://ffmpeg.arrozcru.org/builds/

2- 解压文件并将 ffmpeg.exe 复制到您的网站

3- 使用以下代码:

Process ffmpeg;

string video;
string thumb;

video = Server.MapPath("first.avi");
thumb = Server.MapPath("frame.jpg");

ffmpeg = new Process();

ffmpeg.StartInfo.Arguments = " -i "+video+" -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg "+thumb;
ffmpeg.StartInfo.FileName = Server.MapPath("ffmpeg.exe");
ffmpeg.Start();

1- Get latest version of ffmpeg.exe from : http://ffmpeg.arrozcru.org/builds/

2- Extract the file and copy ffmpeg.exe to your website

3- Use this Code:

Process ffmpeg;

string video;
string thumb;

video = Server.MapPath("first.avi");
thumb = Server.MapPath("frame.jpg");

ffmpeg = new Process();

ffmpeg.StartInfo.Arguments = " -i "+video+" -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg "+thumb;
ffmpeg.StartInfo.FileName = Server.MapPath("ffmpeg.exe");
ffmpeg.Start();
北座城市 2024-07-13 02:45:59

www.mitov.com 上的一些库可能会有所帮助。 它是 Directshow 功能的通用包装器,我认为其中一个演示展示了如何从视频文件中获取帧。

There are some libraries at www.mitov.com that may help. It's a generic wrapper for Directshow functionality, and I think one of the demos shows how to take a frame from a video file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文