Java 视频处理库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13011397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 11:08:56  来源:igfitidea点击:

Video Processing Library for Java

javavideo-processinggstreamerjmfxuggle

提问by abhishek

I want to extract frames from a video and apply some filters on it such as gabor/hough etc. Which Java library would be perfect for handling all kinds of video encodings? I have been looking at GStreamer, JMF, Xuggler etc. but am unable to decide which one would be the best. I'm also looking to edit the frames and make the video with the new frames.

我想从视频中提取帧并对其应用一些过滤器,例如 gabor/hough 等。哪个 Java 库最适合处理各种视频编码?我一直在研究 GStreamer、JMF、Xuggler 等,但我无法决定哪一个是最好的。我还希望编辑帧并使用新帧制作视频。

回答by Michael Berry

If you're looking to do low level operations such as extracting frames and manipulating them, then Xuggler would be the best choice, because the APIs are geared around this low level. It works on ffmpeg so can handle all types of video encodings.

如果您希望进行低级操作,例如提取帧和操作它们,那么 Xuggler 将是最佳选择,因为 API 是针对这种低级的。它适用于 ffmpeg,因此可以处理所有类型的视频编码。

Don't use JMF for anything, it's old, outdated and buggy - GStreamer is good, but the API lends itself more to playing videos rather than manipulating the frames.

不要将 JMF 用于任何事情,它很旧、过时且有问题 - GStreamer 很好,但 API 更适合播放视频而不是操作帧。

回答by Gabriel Ambrósio Archanjo

You can try Marvin Framework. It uses JavaCV for video encodings and device access, but all image processing algorithms are pure Java.

你可以试试Marvin 框架。它使用 JavaCV 进行视频编码和设备访问,但所有图像处理算法都是纯 Java 的。

It's very easy to load a video and process the frames in real time, as shown in the edge detection example below.

加载视频并实时处理帧非常容易,如下面的边缘检测示例所示。

enter image description here

在此处输入图片说明

Source code:

源代码:

import static marvin.MarvinPluginCollection.*;

public class SimpleVideoProcessing extends JFrame implements Runnable{

    private MarvinVideoInterface    videoAdapter = new MarvinJavaCVAdapter();
    private MarvinImagePanel        videoPanel = new MarvinImagePanel();
    private MarvinImage             videoFrame, videoOut = new MarvinImage(640,480);

    public SimpleVideoProcessing() throws MarvinVideoInterfaceException{
        super("Simple Video Processing using Marvin");
        add(videoPanel);
        // Load video file and start the processing thread
        videoAdapter.loadResource("./res/snooker.wmv");
        new Thread(this).start();
        setSize(640,500);
        setVisible(true);
    }

    public void run() {
        try {
            while(true){
                // Request, process and show the video frame.
                videoOut.clear();
                videoFrame = videoAdapter.getFrame();
                prewitt(videoFrame.clone(), videoOut);
                videoPanel.setImage(videoOut);
            }
        } catch (MarvinVideoInterfaceException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws MarvinVideoInterfaceException {
        new SimpleVideoProcessing().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

回答by boomz

JMF is a good choice. But if the process time is important in your code, it's better to use Xuggler. Obviously, JMF is more general than Xuggler.

JMF 是一个不错的选择。但如果处理时间在您的代码中很重要,那么最好使用 Xuggler。显然,JMF 比 Xuggler 更通用。

回答by saurabheights

Xuggler, yes. But if you are going to be working on a lot of Image processing, you should go with OpenImaj. This library uses Xuggler as its dependency, but that's not all what it does. Think of having capabilities of Opencv without the lack of speed which you get in Java. Also, all it requires is adding a maven dependency and you are good to go. The amount of code is also reduced.

许格勒,是的。但是,如果您要进行大量图像处理,则应该使用OpenImaj。该库使用 Xuggler 作为其依赖项,但这并不是它的全部功能。想想在不缺乏 Java 速度的情况下拥有 Opencv 的功能。此外,它所需要的只是添加一个 maven 依赖项,您就可以开始了。代码量也减少了。

Note: I am still reviewing the library and will keep updating my answer on how this goes.

注意:我仍在图书馆,并将继续更新我的答案。

Introductory Video: https://www.youtube.com/watch?v=TNEQ0eNqLgA

介绍视频:https: //www.youtube.com/watch?v=TNEQ0eNqLgA