使用 C# 从 flv 中提取关键帧

发布于 2024-09-28 08:37:42 字数 33 浏览 0 评论 0原文

有没有办法使用 C# 从 flv 文件中提取关键帧?

Is there a way to extract a keyframe from flv file using C#?

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

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

发布评论

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

评论(1

缪败 2024-10-05 08:37:43

找不到直接的方法来做到这一点。

不过,您可以在 C# 中使用 FFmpeg.exe

在这里您可以找到一个 C# 包装器,以便在 C# 中轻松使用 FFmpeg:

http://www.ffmpeg-csharp.com/

以下代码取自其示例页面。似乎您可以通过以下方式提取帧并从中创建缩略图:

CAVConverter converter = new CAVConverter();
//...

使用 converter.AVPrope.Decode(-1) 解码下一帧和 converter.AVPrope.CurrentPicture 获取缩略图。使用converter.AVPrope.SaveCurrentFrame(fileName)将当前帧保存到文件fileName。

//Load the file
converter.AVPrope.LoadFile(fileName, "");
//Decode the frame converter.AVPrope.Decode(-1);
//Get the thumbnail picture. It is a IPictureDisp object, do something as you need.
var thumbnail = converter.AVPrope.CurrentPicture;
//Save current frame to file fileName
converter.AVPrope.SaveCurrentFrame(fileName);

希望有帮助。

Can't find a direct way of doing this.

However you can use FFmpeg.exe in C#.

Here you can find a C# wrapper to easily use FFmpeg in C#:

http://www.ffmpeg-csharp.com/

The following code is taken from their sample page. Seems like you can extract frames and create thumbnails from them in the following manner:

CAVConverter converter = new CAVConverter();
//...

Use converter.AVPrope.Decode(-1) to decode the next frame and converter.AVPrope.CurrentPicture to get the thumbnail picture. Use converter.AVPrope.SaveCurrentFrame(fileName) to save current frame to the file fileName.

//Load the file
converter.AVPrope.LoadFile(fileName, "");
//Decode the frame converter.AVPrope.Decode(-1);
//Get the thumbnail picture. It is a IPictureDisp object, do something as you need.
var thumbnail = converter.AVPrope.CurrentPicture;
//Save current frame to file fileName
converter.AVPrope.SaveCurrentFrame(fileName);

Hope it helps.

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