逐帧访问视频

发布于 2024-08-06 22:48:04 字数 95 浏览 2 评论 0原文

什么是最容易编码的技术,它可以让我实时访问视频帧并允许我修改它们。我知道DirectShow,但它的编程模型似乎相当复杂。是否有一个框架可以使这样的框架过滤器的编程变得更容易?

What is the easiest-to-code-in technology that would give me real time access to a video's frames, and allow me to modify them. I am aware of DirectShow, but it's programming model seems to be quite complicated. Is there a framework that makes programming such a frame filter easier?

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

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

发布评论

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

评论(9

倒数 2024-08-13 22:48:04

<块引用>

让我实时访问视频帧,并允许我修改它们

您是否希望获取未压缩的视频帧并在渲染之前对其进行修改?或者您想修改视频帧,将它们保存回媒体文件吗?

第一个会稍微容易一些。尽管 DirectShow 乍一看可能很复杂,但它确实是一个优雅的框架。我强烈建议查看 DirectShow.NET 示例。要访问视频帧,您只需配置 SampleGrabber 过滤器并将其添加到 DirectShow 图形中,执行 graph.RenderFile(mymediafile, null),然后您将收到每个帧的回调。您可以修改像素数据,它将显示在渲染的视频上。这不应占用超过 1 页的代码。我有一个使用 SampleGrabber 的示例源代码,但它是为网络制作的相机。播放媒体更加容易(graph.RenderFile!)。

如果您需要将这些内容写入文件,您可以执行与上述类似的操作,但您必须配置图形以使用视频编码器和复用器,而不是使用视频渲染器。对于刚接触 DirectShow 的人来说可能不好玩;)。

如果您只想获取帧,则 directshow 中有一个非常简单的界面,称为 IMediaDet。我编写了一个简单的类来轻松从媒体中提取任何帧文件。它面向 WPF,但您可以将其与直接 GDI 一起使用。

Give me real time access to a video's frames, and allow me to modify them

Are you looking to get the uncompressed video frames and modify them before they are rendered? Or do you want to modify the video frames, saving them back to a media file?

The first one would be slightly easier. Even though DirectShow may seem complicated at first, it really is an elegant framework. I would strong suggest looking at the DirectShow.NET samples. To get access to the frames of the video, you'd simply configure and add a SampleGrabber filter to the DirectShow graph, do a graph.RenderFile(mymediafile, null), and you will receive a callback for each frame. You can modify the pixel data and it will appear on the rendered video. This should not take more than 1 page of code. I have an example source code on using SampleGrabber, but it's made for web cameras. Playing media is much easier (graph.RenderFile!).

If you need to write this stuff to a file, you'd do something similar to what is described above, but instead of using a video renderer, you'd have to configure the graph to use video encoders and muxers. Probably not fun for someone new to DirectShow ;).

If you just wish to get frames there is a VERY simple interface in directshow called IMediaDet. I have written a simple class to easily extract out any frames from a media file. It's geared towards WPF, but you can gut it to work with straight GDI.

眼眸印温柔 2024-08-13 22:48:04

您可以查看 ffmpeg 命令和开源项目,它使用了 libavcodec 库。

You can take a look at ffmpeg command and open-source project, which uses libavcodec library.

耶耶耶 2024-08-13 22:48:04

我不知道您到底想要实现什么,所以这可能对您没有帮助,但如果您只需要动态更改视频的帧,我强烈建议您查看 AviSynth。它是一个视频帧服务器,使用脚本语言来更改视频。还有一个 SDK,您可以使用它来编写二进制插件。已经有很多插件可以用来完成各种任务。示例脚本如下所示:

AviSource("C:\video.avi")
Crop(20,0,-20,0) //Crops 20px from the left and right of video 
BicubicResize(640,480) //Resize to 640x480 using bicubic filter
# increase the gamma
Levels(0, 1.2, 255, 0, 255)

然后可以在媒体播放器或编码器(例如 Virtualdub)中打开这些脚本。

I have no idea what exactly you are trying to achieve so this may not help you, but if you just need to alter the frames of a video on the fly, I would highly recommend looking into AviSynth. It is a video frameserver that uses a scripting language to alter video. There is also an SDK for it that you can use to write binary plugins. There are a lot of plugins already available to accomplish various tasks. An example script would look like this:

AviSource("C:\video.avi")
Crop(20,0,-20,0) //Crops 20px from the left and right of video 
BicubicResize(640,480) //Resize to 640x480 using bicubic filter
# increase the gamma
Levels(0, 1.2, 255, 0, 255)

These scripts could then be opened in a media player or encoder such as Virtualdub.

蘸点软妹酱 2024-08-13 22:48:04

好吧,既然你问的是“简单”,那我就不得不提一下 HTML5

OK, since you asked for "easy", I have to mention HTML5 <video>. See the demo and explanation at these links:

零度° 2024-08-13 22:48:04

Hy Opencv 正是您所需要的。它是一个框架,您可以操作图像、视频和更多东西,请查看 http://opencv.willowgarage。 com/wiki/

Hy Opencv is what you need. Its a Framework which can you can manipulate image,video and alot more thing check out http://opencv.willowgarage.com/wiki/

﹉夏雨初晴づ 2024-08-13 22:48:04

不久前,MS 的一些 C++ 包中有一个名为 AviFile 的类。我不知道发生了什么事。

如果您坚持使用 Windows,解决此问题的最佳方法是使用 DirectShow。

AVI 文件格式(有详细的文档,您可以在 google 下找到)有点类似于:

AVIRIFF  size speed imgWidth imgHeight frameTotal imgCodec audioCodec frame size 
  FRAME
  SOUND
  FRAME 
  SOUND

There was a class called AviFile in a few C++ packages from MS a while back. I'm not sure what happenend to that.

The best way to go about this problem is to use DirectShow if you are sticking with windows.

The AVI File format (which is well documentent and you can find under google) is a bit similar to:

AVIRIFF  size speed imgWidth imgHeight frameTotal imgCodec audioCodec frame size 
  FRAME
  SOUND
  FRAME 
  SOUND
半窗疏影 2024-08-13 22:48:04

考虑创建一个 VLC 插件

在 Linux 和 Windows 上运行,支持实时直播视频、文件流、大量编解码器等。

Consider creating a VLC plug-in

Runs on Linux and Windows, supports real-time live video, streaming from file, loads of codecs etc.

仅此而已 2024-08-13 22:48:04

最简单的解决方案是使用 AVIFile API
有很多可用的样品。

the simplest solution is using the AVIFile API.
the are many samples available.

拧巴小姐 2024-08-13 22:48:04

您可以使用FFMpeg

查看 FFmpeg 文档

You can use FFMpeg.

Check the FFmpeg documentation

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