缩略图视频 C#

发布于 2024-08-09 21:25:48 字数 97 浏览 1 评论 0原文

是否可以在 C# 中创建视频的缩略图(如第一帧)?

小更新:我需要 C# 中的 FLV 视频的缩略图,因为我使用 Flex 来显示视频。是的,一些库的链接会很有用。

Is it possible to create a thumbnail image of a video in C# (like the first frame)?

Little update: I'll need a thumbnail image of an FLV video in C# since I'm using Flex to show video's. And yes, links to some libraries would be useful.

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

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

发布评论

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

评论(3

翻了热茶 2024-08-16 21:25:48

我立即想到了两个选项:

  1. 使用外部工具(例如 ffmpeg)来生成缩略图。这可能是该问题最常用的解决方案。
  2. 解析 FLV 文件并仅将文件发送到第一个 I 帧 的末尾。 (您可以在代码中找到解析逻辑,该逻辑允许您按时间标记查找 FLV 的中间位置。

I can think of two options off the top of my head:

  1. Use an external tool, like ffmpeg, to generate thumbnails. This is probably the most commonly implemented solution to this problem.
  2. Parse the FLV file and only send the file only to the end of the first I Frame. (You can find the parsing logic in code that allows you to seek into the middle of an FLV by time mark.
待"谢繁草 2024-08-16 21:25:48

您可以使用一些开源库来执行此操作。查看 OpenCVDotNet,它是 OpenCV,一个“计算机视觉”库。 这是一个教程链接,您可能会觉得有用。

There are Open Source libraries you can use to do this. Check out OpenCVDotNet, a managed .NET wrapper for OpenCV, a "computer vision" library. Here's a link to a tutorial you may find useful.

荭秂 2024-08-16 21:25:48

这有效:

ShellFile thumbNail = ShellFile.FromFilePath(<fullpath and filename>);
Bitmap thumbSmall = thumbNail.Thumbnail.MediumBitmap;
Bitmap thumbLarge = thumbNail.Thumbnail.LargeBitmap;
videoThumb_Small.Images.Add(thumbSmall);
videoThumb_Large.Images.Add(thumbLarge);

其中“videoThumb_??????” = ImageList(在其中控制要再次显示的图像的大小)。搜索不同的 MIME 格式时速度慢得要命,但搜索相同类型时却足够快。需求:

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack;

并且您可以从同名的nuget包中获取Microsoft.WindowsAPICodePack。至于 FFMpeg、Vlc.Dotnet 或 aXMediaPlayer(WMP),据我测试,它们都很糟糕(Vlc 甚至无法正常工作,FFmpeg 再次需要 5 亿行才能获得相同的结果,aXMediaPlayer 也很好,呵呵)除此之外,这是 Windows 原生的。

例如,如果您将 ListView 与子项之类的东西一起使用,则:

for(int mememe = 0; mememe < stuff_counter; mememe++)
{
listview1.Items.Add("strings", mememe).SubItems.Add("strings" + mememe.ToString());
}

然后会从 ImageList 读取正确的索引号

This works:

ShellFile thumbNail = ShellFile.FromFilePath(<fullpath and filename>);
Bitmap thumbSmall = thumbNail.Thumbnail.MediumBitmap;
Bitmap thumbLarge = thumbNail.Thumbnail.LargeBitmap;
videoThumb_Small.Images.Add(thumbSmall);
videoThumb_Large.Images.Add(thumbLarge);

where 'videoThumb_?????' = ImageList (where to control size of the image to display again). Slow as hell when searching different MIME formats, but fast enough with same types. Needs:

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack;

and you can get Microsoft.WindowsAPICodePack from nuget package with same name. As for FFMpeg, Vlc.Dotnet or aXMediaPlayer(WMP) they all suck as far I've tested(Vlc doesn't even work as it should, FFmpeg again needs 500 million lines before you get same result and aXMediaPlayer well, heh) them beside that's Windows native.

Example, if you're using ListView with something like subitems even:

for(int mememe = 0; mememe < stuff_counter; mememe++)
{
listview1.Items.Add("strings", mememe).SubItems.Add("strings" + mememe.ToString());
}

Would then read the correct index number from ImageList

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